AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
2K members online now
2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Google Analytics re-initialize

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I initialize ga with:

 

1) ga('create, 'UA-XXX-Y'); 

 

2) Now while my application starts up, I realize that I need to re-initialize with a new tracking id. so I do :

ga('create, 'UA-XXX-Z');

 

The reporting is still done to  the account, 'UA-XXX-Y'.

What change should I make to get the reporting switched to the second tracking id, 'UA-XXX-Z'  ?

 

thanks!

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Dhanya M
December 2016

Re: Google Analytics re-initialize

Follower ✭ ✭ ☆
# 4
Follower ✭ ✭ ☆

Hi Dhanya

 

Can you delete the line of UA-XXX-Y ?

If it can not be deleted for reasons such as begining generated by CMS, please try remove command. The command example is following.

 

ga('create', 'UA-XXX-Y');
ga('remove');  // remove "UA-XXX-Y" tracker.
ga('create', 'XXX-Z');

Thanks

View solution in original post

Google Analytics re-initialize

Top Contributor
# 2
Top Contributor

Hi,

 

Please check the document below about working with multiple trackers:

https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers#working_w...

"To track data for two separate properties, you need to create two separate trackers, and at least one of them must be a named tracker."

Let me know if you have questions.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Google Analytics re-initialize

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

I don't want multiple trackers. 

what I want to do is re-create the ga object with a different tracking id.

 

var a =  ga('create, 'UA-XXX-Y'); 

a = ga('create, 'UA-XXX-Z'); 

 

I want the second instance to replace the first one.

Is that possible?

Marked as Best Answer.
Solution
Accepted by topic author Dhanya M
December 2016

Re: Google Analytics re-initialize

Follower ✭ ✭ ☆
# 4
Follower ✭ ✭ ☆

Hi Dhanya

 

Can you delete the line of UA-XXX-Y ?

If it can not be deleted for reasons such as begining generated by CMS, please try remove command. The command example is following.

 

ga('create', 'UA-XXX-Y');
ga('remove');  // remove "UA-XXX-Y" tracker.
ga('create', 'XXX-Z');

Thanks