I want to track the stats for my website with custom GET parameters instead of utm parameters.

With UTM the URL gets longer and messy.


What I would like is a URL like this


Then somehow tell Google Analytics to track the parameter ref=fb

3 Answers 3


You can set up Custom Dimensions in Google Analytics. First, I would recommend upgrading to Universal Analytics then do the following:

  1. Sign in to Google Analytics.

  2. Click Admin from the menu bar at the top of the page.

  3. From the dropdown menus, select an account and a property to which you want to add custom dimensions.

  4. Under the Property column, click Custom Definitions, then click Custom Dimensions.

  5. Click New Custom Dimension.

  6. Add a Name. This can be any string, but use something unique so it's not confused with any other dimension or metric in your reports.

  7. Select the Scope. Choose to track at the Hit, Session, User, or Product level. Read more about scope and how custom dimensions are processed in our Developer Guide.

  8. Check the Active box to start collecting data and see the dimension in your reports right away. To create the dimension but have it remain inactive, uncheck the box.

  9. Click Create.

Once you have your Custom Dimension created, you can use this function to send the hit to Google Analytics. This example uses PHP and you would need to create a Custom Dimension called ref.

    { ?>
            ga('send', 'pageview', {'ref':  '<?php echo $_GET["ref"]; ?>'});
  • Coperland - Thanks for the answer! Where can I see the analytics report for this specific hit? Jan 8, 2015 at 10:10
  • @AlokTripathy you can break any report down by a dimension. see my screenshot here - i.imgur.com/qpKXtvh.png Jan 8, 2015 at 16:43
  • So it's really the case that if you want to track non utm url parameters, you have to add custom JS code to your pages?
    – AdamJones
    Mar 6, 2017 at 14:56

If you use Google Tag Manager then you can capture the value of the URL fragment and then match it with your Lookup Table macro. This is a much more efficient way of doing this.

1) Create a new Macro (Macro Type: URL -> Component Type: Fragment)

2) Create another Macro (Macro Type: Lookup Table)

a) enter all of your items such as fb, twitter, linkedin
b) use the macro from step one to match 'When {{macro1name}} equals'

3) Setup a new dimension in Google Analytics

4) Go to your Pageviews tag in GTM and under Custom Dimensions add your dimension index and the second micro.


I found a way to add this GTM method directly into GA source and medium variables.

I applied the same GTM macros described above: URL Fragment and Lookup Table. I added a common start code ("cid") to each URL Fragment and that would go into table column 1. The column 2 would be the extended campaign description. Lookup table looks like this: 1) cid-fb1 / facebook_video-ads 2) cid-fb2 / facebook_link-ads...

I duplicated the GA tag and adjusted the firing rules: 1) One only fires when the URL Fragment starts with "cid" and replaces campaign source tracking for the Lookup Table value. 2) The generic GA tag was kept the same but one only firing when the "cid" URL Fragment is not there.

So a link http://example.com#cid-fb1 would replace campaign tracking and one without "#cid-fb1" it would not.

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.