A little background - I handle our website analytics and our email marketing team is asking if we can track how many times a link in one of their emails is clicked.

Normally I would say that's easy but in this case the link goes to our App's page in the Google Play Store, so we can't simply track it with our GA installation.

Since you can't use script tags in email HTML, I am now wondering if the best way would be to track via 301 redirect, i.e. give the link an href that includes the email campaign information, 301 that to the Google Play Store address.

Obviously this is more cumbersome to have to look at our site logs to get this data, but it seems like the only reliable method.

1 Answer 1


Here is how I've set up tracking for these types of links in the past. I've used a redirect but the trick to track in GA is to use a client-side redirect vs. a server-side redirect. The client-side redirect can route through a page that triggers the GA code to fire.

Here is the setup I've used for this before:

  • Create an empty page on your website. Ideally, this can be a completely blank page but the simpler you can make it the faster it will load for the end user.
  • On that page, add in the GA code as you normally would for any other page of your website. That way this shows up as a page in GA reports.
  • After the GA code, put in the JS code to redirect to the destination (in this case the Play Store address).
  • Link to that page in your email newsletter.

A few issues:

  • This will track the clicks as a pageview. I tend to find that is the simplest because you can look up in standard GA reports (in your case, look up /google-play.html or whatever name you gave that redirected page). However, instead of putting the GA code on there, you could use a custom metric instead (you create the custom metrics and load it as an image on the blank page). That way you aren't skewing pageviews.
  • This will track client-side where your option of a server-side 301 redirect would track on the server. As with all client-side tracking, things could get missed. The faster you can have the page load, the more reliable the tracking though.

Hope that helps.

  • Thanks Matthew. Do you find that it is more accurate if there is a longer delay on the JS redirect? For example, using a "you are being redirected" message that flashes for a second or two, instead of immediately redirecting?
    – Jake 1986
    Commented Sep 17, 2021 at 21:11
  • @Jake1986 Yeah, if you can slow the redirect down that can help make sure the GA code fires correctly. You'll want to test out the speed of the page to see how quickly it fires. Typically, you don't need to give it very long for GA to track. Commented Sep 22, 2021 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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