1

I want to track custom GET parameters with Google Analytics. I don't want to create anything inside the GA account (UTM and the rest of it). I've added this to my code:

<script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
        (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
        m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'xxxxxxxx', 'auto');
    // set of parameters tracked
    ga('set','parameter','value');
    ga('set','anotherparam','anothervalue');
    ga('set','customparam','customvalue');
    ga('send', 'pageview');
</script>

This was tested simply by visiting

www.mysite.com/somepage.html?parameter=value

Or

www.mysite.com/another-page.html?anotherparam=anothervalue

etc.

After opening links directly, and checking GA dashboard / panel at the same time, the links were visible in the Realtime section. However, not all of them were visible inside Acquisition or Behavior parts of GA dashboard. As far as I can tell, there are no patterns to when the landings are detected (the links are opened on both a desktop PC running Windows, and Android phone via Google Chrome, sometimes they are visible, other times they're not visible).

Finally, my question.

How can I capture page landings with a custom GET parameter, without the UTM tracking codes? Can it be done through my JavaScript code alone? I do not want to create custom dimensions and custom definitions inside Google Analytics.

EDIT For clarification, the parameter is added to a URL which does not have it originally. The reason I'm doing this is to be able to track visits from specific campaigns (for example, clicks on a link within an email, or a banner click, etc). So, the original link might be:

www.mysite.com/somepage.html

and I'm ocassionally turning it into

www.mysite.com/somepage.html?parameter=value

I want to be able to see both somepage.html and somepage.html?parameter=value as distinct, separate entries in Google Analytics dashboard. If anyone types in somepage.html?randomname=randomvalue, I want to be able to see that too. Kind of like going through the websites access logs, and grouping accessed links by their entire URL.

  • 1
    Are you trying to add parameters to a visited URL that doesn't originally have them? The URL that is visited, with parameters, should be by default the value sent to GA for the Page dimension. – Reve Nov 20 at 17:35
  • Not quite what I'm doing - the parameter is sort of grafted on, and the URLs do not originally have any GET parameters (think various social networks and email campaigns, with the value of the parameter being subject to change). – FiddlingAway Nov 20 at 18:17
  • Let me make sure I understand: the visitor clicks a link that does not have parameters, and then once they arrive at your site the code adds parameters before sending the hit to GA. So the goal is to get URLs with parameters to show in GA reports without having to add the parameters to the original link? – Reve Nov 20 at 21:19
  • Actually, no. This is what I'm hoping to get (pardon the pun). The URL has the GET parameter only if it's a part of some campaign, or if someone adds it manually in the address bar. It's normally not there. So, what I'm trying to achieve is to make GA register that the parameter is present, and if it is, that specific link (with the parameter) should visible in GA dashboard. If it's a normal looking URL, it should be shown like that. So, I want to make GA show distinction between a link without a parameter, and the same link with a parameter. – FiddlingAway Nov 21 at 11:42
  • Hm. That is supposed to happen by default - unless you're removing the parameters from the visited URL with JS or the Exclude URL Query Parameters view setting, or they're something GA processes and removes like UTM or search, they should just be there. And you're waiting 24 hours for them to show in the non-Real Time reports? – Reve Nov 21 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.