Example #1

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({
	width : 380,
	showLegacyVersion : false,
	showUKVersion : true,
	showItemNameForUK : true,
	showDailySugars : true,
	valueServingWeightGrams : 77,

	dailyValueTotalFat : 70, //this should be 70 for the uk version
	dailyValueCarb : 260, //this should be 260 for the uk version
	dailyValueSugar : 90, //this should be 90 for the uk version

	textCalories : 'Energy',
	textTotalCarb : 'Carbohydrate',
	textFibers : 'Fibre',
	textSodium : 'Salt',

	allowGoogleAnalyticsEventLog : true,
	gooleAnalyticsFunctionName : '_gaNixLabel'
});


Example #2

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({
	width : 380,
	showLegacyVersion : false,
	showUKVersion : true,
	showItemNameForUK : true,
	showDailySugars : true,
	valueServingWeightGrams : 77,

	dailyValueTotalFat : 70, //this should be 70 for the uk version
	dailyValueCarb : 260, //this should be 260 for the uk version
	dailyValueSugar : 90, //this should be 90 for the uk version

	textCalories : 'Energy',
	textTotalCarb : 'Carbohydrate',
	textFibers : 'Fibre',
	textSodium : 'Salt',

	allowTriggerOfUserFunctionOnQuantityChange : true,
	userFunctionNameOnQuantityChange : 'alertMe'
});