Reputation: 71
I'm a back end developer, sometimes a little fronted, but not a SEO related expert at all. Now I have to make a full website from top to bottom and I'm stuck with the Google stuff. First I created a Google Analytics profile, I got the srcipt that I needed to hardcode to all my site.
<script async src="https://www.googletagmanager.com/gtag/js?id=G-MEASUREMENT_ID></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-MEASUREMENT_ID');
</script>
However, a little while later, I started to use Google Ads and it recommended to connect my Analytics page to the Ads page, so I connected them and I got another code that I needed to insert.
The code snippet is almost the same, except the two MEASUREMENT_ID, because now I got a UA-MEASUREMENT_ID.
So, do I have to use both snippets, or just one? If so, which MEASUREMENT_ID should I use? Or am I screwed up something?
Thanks all the help
Upvotes: 0
Views: 266
Reputation: 14179
The code with UA-
(Universal Analytics) and the one with G-
(Google Analytics 4) belong to two completely different tracking systems in Google Analytics. If until now you have used UA-
you should continue to do so and in parallel track with the new one G-
. So you will have two tracking codes at the same time. This is also Google's suggestion not to lose the data history in UA-
.
Upvotes: 1