by Doug


Implementation of Google Analytics

Find legacy GA code after GTM migration

My friend David Vallejo posted some excellent technical articles regarding migrating from hard coded GA to a GTM implementation:

Locating legacy hardcoded events

Finding pages missing GTM snippets.

These techniques are super clever and well worth a read. We’ve found a slightly different use case recently where a GA to GTM migration was not fully completed – there were still GA datapoints that were fired by hardcoded scripts – some were hard to track down so we decided to decorate all GA hits from GTM with a custom dimension and create a view in GA that filtered out hits decorated with the CD giving visibility of all the non-GTM hits.

It goes like this:

Make sure the GTM Container ID built in variable is enabled:

Create the CD in GA:

Decorate all tags with the CD:

Create a new view in GA and add the magic filter:

Now you’ll have a view where all data didn’t come from GTM hits. Hunt them down and fix them up.
It’s worth keeping the view and potentially adding custom alerts to let you know if any spurious tracking finds their way onto your site…


Leave a comment

Your email address will not be published.

ConversionWorks is now Media.MonksVisit us at