Should you set Google Analytics up on the staging site?

A common scenario is for a new website to be built on a test staging server that requires tracking to be implemented. Ideally, you’d want to set all the tracking up on the test site but you don’t want this data going into the main Google Analytics Property since it’s not real data but you do want to be sure all of the tracking is in place and works correctly.

The best way I’ve found to do this is to:

  1. Create a new Google Analytics property just for the test site.
  2. Deploy the Universal Analytics page view tag through Google Tag Manager which is also implemented on the test site.

At this stage, we have enough in place to set up and test the tracking.

  1. Next, deploy another Universal Analytics page view tag that uses the (live site) Google Analytics ID BUT add an exception to the trigger:

The exception is a page view trigger that looks like this:

Where is the hostname of the staging site.

So what we’re saying is – run this page view tag but not if it’s the staging site. This way when the developer moves the site from staging to live our tracking kicks in without our having to do anything and there’s no danger of our live tracking running on the staging site.

The second benefit is that as soon as the site is live our tracking is running!



Author: Kevin Thomson

Head of Analytics & Measurement at Attacat

Leave a Reply

Your email address will not be published. Required fields are marked *