If you're moving from hard-coded @googleanalytics code to Google Tag Manager, here are 3 steps that you need to make to ensure no data is lost in the transition.
A π§΅
Step 1:
Create a Google Tag Manager Container and install it on your website.
Step 2: Use @screamingfrog to confirm that all the pages have the GTM snippet code.
π Go to Configuration > Custom > Search (screenshot 1)
π Configure the rule to find the GTM code you need in the page HTML (screenshot 2)
Now have both codes on the website: Google Tag Manager and Google Analytics.
The GTM should be empty at this point so that your sessions are not double-counted.
The next step should be to remove the GA code. But what happens if you remove it without having a working GA tag in GTM? You'll lose data.
But also, what happens if you for some time will have both hard-coded GA and a GA tag in the Tag Manager? You'll cause data discrepancy
This is a very possible situation, especially if the whole process involves the coordination of multiple departments.
So I'm adding a new step here to mitigate risks: a GA tag in Google Tag Manager that will fire only if there's NO hard-coded GA code in the page HTML -> Step 3
Step 3: Create a variable in GTM that will check if the Google Analytics code is found in the page HTML.
- If it's found -> not fire the GA tag
- if it's not found -> fire the GA tag
#Google ranks pages, not websites. In order to get your page indexed, it should have a separate URL that Google can discover and follow. Here are the main tips to make this happen:
1/5
- Always use an HREF attribute so that Google can easily discover and follow a link
- Ideally, use HTML links. JS links are ok as long as they use an HREF attribute
2/5
- Google wonβt follow and index URLs with fragments (containing #, e.g. store.com/catalog#gifts) as they are not created to lead to a new document/page. So if you want a fragmented URL to be indexed as a separate page, donβt use fragments, e.g. store.com/catalog/gifts
3/5