Basic use of the using the google analytics event feature supplying a renamed google analytics function The code for the google analytics is:
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','_gaNixLabel'); _gaNixLabel('create', 'UA-12345678-9', 'auto');
$('#test1').nutritionLabel({ showLegacyVersion : false, allowGoogleAnalyticsEventLog : true, gooleAnalyticsFunctionName : '_gaNixLabel' });
This is an example where the user function "alertMe" is triggered when the quantity value is changed. The plugin calls the function "alertMe" with 3 parameters 1. kind - textbox / up arrow / down arrow 2. previous value 3. new value The code of "alertMe" is:
function alertMe(kindValue, OldValue, NewValue){ console.log( 'kindValue => ' + kindValue + "\n" + 'OldValue => ' + OldValue + "\n" + 'NewValue => ' + NewValue ); }
$('#test2').nutritionLabel({ allowTriggerOfUserFunctionOnQuantityChange : true, userFunctionNameOnQuantityChange : 'alertMe', showLegacyVersion : false });