Analytics
4.8K members online now
4.8K 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

Old Tracking Code -> replace with new?

[ Edited ]
T G
Visitor ✭ ✭ ✭
# 1
T G
Visitor ✭ ✭ ✭

Hey,

 

Just looking for confirmation.

 

Inherited an old site and needed to quickly make it mobile responsive. Yeah - the company is a little late to the party but getting there none-the-less.

 

The site has old tracking code:

 

 

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

 

I duplicated the site so I can go in and tear it up to make it mobile responsive.

 

As part of the process - can I just go ahead and replace the old tracking code with the new code below?

 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXX-X', 'auto');
ga('send', 'pageview');

Just looking for confirmation. Thanks!

 

Last question - should I use google tag manager with google analytics instead of just tracking code? Will that help track future campaigns?

 

 

 

 

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author T G
February 2016

Re: Old Tracking Code -> replace with new?

Top Contributor
# 2
Top Contributor
Hi,

Yes, you just have to delete the old snippet and replace it with the new one.

Using Google Tag Manager will make future upgrades and enhancements much easier since you don't have to make changes on the website, you can handle everything through GTM.

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

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author T G
February 2016

Re: Old Tracking Code -> replace with new?

Top Contributor
# 2
Top Contributor
Hi,

Yes, you just have to delete the old snippet and replace it with the new one.

Using Google Tag Manager will make future upgrades and enhancements much easier since you don't have to make changes on the website, you can handle everything through GTM.

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

Re: Old Tracking Code -> replace with new?

T G
Visitor ✭ ✭ ✭
# 3
T G
Visitor ✭ ✭ ✭
Thanks Arnold - that is what I thought - just looking for confirmation - especially about the Tag Manager to accomplish all of it.
.