: Two Google Analytics Codes - both not collecting correctly I have inherited a site which has two GA-UA codes. These are setup like this // first code ga('create', 'UA-XXXXXXXX-1', 'auto'); ga('send',
I have inherited a site which has two GA-UA codes.
These are setup like this
// first code
ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('send', 'pageview');
//second code
ga('create', 'UA-XXXXXXXX-1', {'name':'second'});
ga('second.send', 'pageview');
I have no idea why they are setup like this and indeed do not understand the syntax of the second tracking code
The following can be observed
THE FIRST CODE
Custom events working and being successfully collected
Linked successfully to Adwords
Only has a few months of data and therefore we don't want to use this
THE SECOND CODE
Does not record custom events
Can't link to Adwords
Has years of data attached to it that we want to use
The plan is to just use the second code
For complete brevity custom events are being triggered like this
ga('send', 'event', 'Contact', 'contact-form', 'Goals');
My question is this
"Because it has lots of historical data we wish to use code two but it is not collecting custom events. How do I get the second code to collect custom events so we can retire the first code? "
More posts by @Sent6035632
1 Comments
Sorted by latest first Latest Oldest Best
You'd have to modify where the existing (first) tracking code is tracking events. Instead of
ga('send', 'event', 'Contact', 'contact-form', 'Goals');
try:
ga('second.send', 'event', 'Contact', 'contact-form', 'Goals');
The second tracking script has been given a different name in order to differentiate it from the first tracking script, so simply swapping names in the event tracking calls should be enough. Alternatively, remove the first tracker and remove the second tracker's name, thus:
ga('create', 'UA-XXXXXXXX-1', {'name':'second'});
ga('create', 'UA-XXXXXXXX-1', auto);
More info on creating trackers: developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.