1

I've recently launched a new website for a customer, which will for a time run in parallel to their existing site, on the same domain.

I'm trying to find a simple way to setup a Google Analytics filter, to be able to distinguish traffic to the new site.

The catch is that the pages that make up the new site, do not share a common path prefix, so I can't just filter that way.

It's easy for me to add any changes that are required to the gtag snippet for the new site.

I thought perhaps I could do something like this...

gtag('config', 'UA-#######-#', { 'site_version': 'v2.0'});

Then I figured I might be able to create a filter in the Analytics admin, to do something like "tag:site_version=v2.0".

After more research I've realised that these extra options are called "Control parameters", and I apparently can't just make them up, as there is a pre-defined list of valid parameters, none of which seem in any way relevant for what I'm needing to do.

Is there a correct way to do what I'm trying to do? It seems like it should be a trivial requirement, but I'm having trouble finding the solution.

So in short, I want to be able to add some custom 'tag' to the gtag snippet, in order to be able to filter on this 'tag' in the Analytics console.

1

Changing the path in Google analytics

You can use virtual pageviews to track the two versions of the site. For example:

gtag('config', 'GA_TRACKING_ID', {'page_path': '/version1/url.html'});

You could also use document.URL to get the URL

gtag('config', 'GA_TRACKING_ID', {'page_path': '/version1/'+document.URL});

This solution changes the actual dimension path of the site so make sure you always keep a raw data view in Google Analytics.

Adding a new dimension to Google analytics

Another solution is using custom dimensions. Instead of changing the default path dimension, we create a new one (web_version).

gtag('config', 'GA_TRACKING_ID', {
  'web_version': {'dimension1': 'version1'}
});    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.