Setting custom variable on a user interaction


#1

Hi Everyone,

I have a requirement to set a custom variable on a user interaction (a link click). I set up custom variable as below:


$('#someDiv').on('click', '.panel-body a', function() {
            _paq.push([ "setCustomVariable", 2, 'VariableK2', 'variable v2', "page"]);
});

This tracking is inconsistent - means I can see the custom variable report updated but not always on click action. Is it not possible to set custom variable on user action ?Any pointers

Thanks
Ravi


#2

I am facing the same Issue. Is ther any1 who can guide on this ???


(Matthieu Aubry) #3

When you set a custom variable, it does not send a tracking request. So to “measure” how many people clicked on the button use Event Tracking instead (or as well as Custom vars). Call the trackEvent function after setCustomVariable Event Tracking - Analytics Platform - Matomo