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


  • 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


  • 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? "

  • Have you tried removing the first code completely even from analytics / GSC and then trying to use the second code to connect to adwords?
    – DwillX
    Mar 5 '17 at 17:40
  • That is what I am trying next. I will post back.
    – neilc
    Mar 5 '17 at 19:44
  • Sorry but you have already asked the same question on Stack Overflow, cross posting is forbidden. Mar 6 '17 at 21:12

You'd have to modify where the existing (first) tracking code is tracking events. Instead of

ga('send', 'event', 'Contact', 'contact-form', 'Goals');


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: https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers

Not the answer you're looking for? Browse other questions tagged or ask your own question.