We currently use a hashbang for the portion of our site that generates dynamic content which can also be deep linked. Our analytics team wants to use utm params to track the referral traffic from social networks. We are using Universal Analytics (analytics.js) as well as GTM.

Will GA pick up the query parameters after the hashbang or does it always have to go before? For example:


In #1, I'm concerned that the utm params won't be recorded and in #2 the page will break or the url could be incorrectly written. How does GA pull in those parameters - location.search? regex?

Can I get away with using either?

  • Have you already found a solution for this? I'm dealing with the exact same issue, where I don't see the utm tagging in GA. For example with this URL: vandebron.nl/#!/s/…
    – user39131
    May 30, 2014 at 13:45

5 Answers 5


I dont think the GA will kick-in after #!

I guess (and correct if my speculation is wrong), that your #! site is using the front controller pattern (just like WordPress and its index.php).

In which case, can't you tweak your framework to move away from #! and towards something more friendlier? Your problem is that # generally indicates anchor tags within the page. So, anything which comes after the # is not interpreted separately.


I used this:


ga('create', 'UA-XXX-X', {'allowAnchor': true});
ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});

After implementing this, anchor style URLs appear along side normal pages in Analytics reports.

Found on:



I ran into this same issue at a previous company and it was a mess (one guy actually lost his job due to bad URLs being used for tracking paid search and no one understanding why GA showed different results than Kenshoo...).

You can come up with a custom workaround using JavaScript to inspect the URL query string to look for UTM params after a #! then rewrite the page that gets tracked.

If you decide to go the route of custom JavaScript to deal with it this may be useful. Here is the reference for setting the various UTM values on your own in code.

So without adding custom JavaScript or rewriting the system to remove the hashbangs, there really isn't a way to deal with this. Honestly though you should do whatever you can to move away from #! URLs.


Try replacing




This worked for me.


You also could try the “fields to set” functionality in GTM to transform URL-parameters to the campaign parameters used for Google (https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignSource). I’m only not sure if GTM pick up the URL after the #.

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.