Analytics tracking

The Redirect plugin allows you to track redirects directly in Google Analytics. There are however a few things to keep in mind, so read all the info below!

Setting up the basics

Here are the steps:

  1. First, open up your app-level redirect.conf.ini and set the redirect_analytics
  2. If you’ll be redirecting cross-domain, then please take a look at the cross-domain guide below.

Cross-domain tracking

When you are using the same Analytics account across your source and destination domains (this is often the case if you are using it as a url shortener for example) then you need to take additional steps to ensure proper tracking.

Each time the redirection happens a new client id is generated, the page view and event is tracked from the server-side, and the user is then redirected to the destination. If the source and destination domains are different, you need to modify the GA init code on your destination domain as follows:

ga('create', 'UA-XXXXXXX-Y', 'auto', {
  {% if ofw.get.clientId and ofw.get.clientIdValidity > %}
    clientId: '{{ofw.get.clientId|escapejs}}'
  {% endif %}

This will ensure that the client id is preserved while also limiting its validity if the url is directly shared (for example, with the ?clientId parameter).

Important! If the cross-domain handling is not set up properly then your user count will be doubled as each user is counted twice (once on the old domain, again on the new domain).

Setting up Analytics

In case the redirection happens across domains, you will need to apply an additional setting in Google Analytics to make the tracking perfect.

Go to Admin / View settings and add clientId,clientIdValidity under “Exclude URL query parameters”.

2016-11-17 at 14.32

What will you see in Analytics?

The Redirect plugin will track two different things each time a user goes through the redirection:

  • Page view – A virtual page view will be tracked as redirect/go/path with “path” being the source url you set up in the redirection admin.
  • Event – This event will be tracked in the category Redirect with the action Go and the label will be the source url /path that was set up in the redirection admin.

Also, take note of the following:

  • Any time a user hits the redirection a new client id will be generated. This means that each time the user clicks a redirect link he/she will be considered a new user. This is typically not a problem for marketing campaigns but it is definitely something to be aware of!
Outlast Web & Mobile Development (c) 2019 | Privacy Policy |