Rich-text Reply

Will a redirect experiment mess with tracking in Google Analytics?

adam_paxton 02-24-15
Accepted Solution

Will a redirect experiment mess with tracking in Google Analytics?

Hi,

 

Very much a newbie here but my question is this:

 

I am looking to setup a split test of multiple thank-you pages I have built on my site. These are physical pages on the server rather than pages I have built using the editing tools. From what I have read it seems the obvious way to set this up is to use the redirect settings on the variants. However, I am concerned that because it's using a redirect it's going to give me double hits in my Google Analytics Goal tracking. Is this the case and, if so, is there a way around this?

 

My pages are:

 

mysite.co.uk/thank-you

mysite.co.uk/thank-you-sidebar

mysite.co.uk/thank-you-modal

 

I have a goal in Google Analytics tracking users landing on any page containing /thank-you. So this tracks my 3 variations listed above.

 

My plan was to setup the redirect experiment on optimizely like so:

 

- Set the 'original' page to be /thank-you

- Setup variation #1 to redirect to /thank-you-sidebar

- Setup variation #2 to redirect to /thank-you-modal

 

But I assume that all users are going going to hit /thank-you and then for some, they will be instantly bounced to /thank-you-sidebar or /thank-you-modal (and never see the original). But for these redirects I am guessing the Google Analytics tag would fire on both the /thank-you and then the final page they end on (either /thank-you-sidebar or /thank-you-modal).

 

So the question is - am I right in my thinking and this is going to mess with my GA tracking? Is there a better way to setup my test in Optimizely? Is there a way around this double counting in Google Analytics?

 

Thanks in advance for the help!

 

greg 02-24-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

Since the Optimizely code is higher on the page than the Google code, it will redirect the user before Google tracks the pageview. So the short answer is no, it should not track with your Google Analytics goals. But always double-check!

Level 2
adam_paxton 02-24-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

Hi Greg,

 

Firstly - Thanks for the reply!

 

I would normally deploy through Google Tag Manager (GTM) so I'll try to take advantage of the 'Tag Firing Priority' setting in GTM and see if that works.

 

Many thanks

 

 

greg 02-24-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

It's best to NOT deploy Optimizely through GTM. Both Optimizely and Google say so, and from my experience I strongly agree.

 

The reason is that both the GTM and Optimizely scripts load asynchronously, and the tag firing order setting is not reliable. If you want to effectively use Optimizely with GA, I strongly suggest loading Optimizely directly on the page, in the <head> tag as recommended.

 

 

Level 2
Joel_Balmer 02-25-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

Hi Adam, yes Greg is absolutely right!

 

The Optimizely snippet works best when it is a the top of the head, synchronously. This is because it has time to interact with the page early on, affect any changes, make sure data is tracked, captured / passed correctly.

 

If you have Optimizely asynchronous we can't guarantee at which point it will finish loading and be tracking, so it's possible no data would be passed to GA, as the GA integration depends on specific timing for it to work (i.e. the Optimizely snippet to be loaded first).

 

However, it is possible to load the Optimizely snippet and GA through the tag manager by using the data layer event, as shown in our article section on this, here. This will make sure your GA is integrated with Optimizely, but because you're loading optimizely through a tag manager it will be asynchronous and may cause isues with 'flashing', etc.

 

I hope that complements Greg's comments, and sheds a little more light on the situation!

adam_paxton 02-25-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

Hi,

 

Yeah, Greg had it spot on. Took the snippet out of GTM and moved into the <head> and it seems to work a treat!

 

Next task is to work out how I stop getting hits against my goal in Analytics when the Optimizely editor hits the page in it's preview. I tried setting up a filter to exclude referer = optimizely.com but I don't think that has caught them all. Still, that is another question for another time if I can figure it out.

 

Thanks for all the help, great community and excited about the product!

greg 02-25-15
 

Re: Will a redirect experiment mess with tracking in Google Analytics?

I believe adding a hostname filter to your Google Analytics view should do the trick. Add a filter to include only traffic to yourdomain.com. See "Exclude/Include only traffic to the hostname": https://support.google.com/analytics/answer/1033162?hl=en#PredefinedFilters

Level 2