Reputation: 471
I have a HTML single page application (it is a single HTML file, where i show page navigation as hiding and showing multiple div elements, so page navigations are not actual page loads, just switching divs)
I have created some 5 custom dimensions of "Session" scope, so they will be always present and tracked with some value.
However, I need a 6th dimension which will be populated only upon doing a particular operation such as clicking a button. So i have created 6th dimension and set its scope as "Hit". In the HTML application, as soon as the user clicks the button, i set the value for that dimension and do a send for that request (it is actually an 'ec' tracking), i can see that the 6th dimension value is also set.
The problem is, After this tracking, if i track any other event tracking or page view tracking, the same value is being passed for the cd6 parameter.
Could you please let me know if i am doing anything wrong here?
Upvotes: 1
Views: 626
Reputation: 32760
If you set a custom dimension via set it will apply to all hits that follow:
ga('set', 'dimension1', 'mydata');
will attach the dimension to all following tracking calls (especially bad on a single page app).
You can pass a JSON object as second parameter to the ga("send") call instead and set the dimension there:
ga('send', {
'dimension1': 'mydata',
});
That way the dimension is only sent with that pageview, later interactions will not be affected.
Upvotes: 2