Analytics
2.1K members online now
2.1K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Can specific URL parameters be filtered/tracked?

Google Employee
# 1
Google Employee

This question, originally asked by Marc Amos was copied from the old Google Analytics product forum.

 

Here's my situation and what I'd like to do:

I offer a JavaScript-based widget that other folks can put on their website. Inside of the widget are my latest news stories, each of which link back to my own site, to the specific story page.

Currently, there's no barrier to obtaining the widget and installing it on a website, so I'm not able to track exactly who is using the widget on their site. What I intend to do, in JavaScript, is code it so each of the story-links append a certain parameter to the URL that defines the 'current location.'

For example, if "abcwebsite.com" is using my widget, and somebody clicked on a news story while on abcwebsite.com, the URL that brings them to my story page would be:

http://www.mywebsite.com/a-particular-story.php?referrer=abcwebsite.com

So, as you can see, each incoming link would have a unique referrer value appended to it that lists the domain of where the widget is installed. My hope is that I can use this data to track who is using my widget.

So, can something like a URL parameter value be tracked/reported in Google Analytics?

Thanks!

2 Expert replyverified_user

Can specific URL parameters be filtered/tracked?

Google Employee
# 2
Google Employee

This answer was provided by "E-Nor Rehan" and copied from the old Google Analytics product forum.

 

Hi,

You could update the URL parameters to be something like this:
http://www.mywebsite.com/a-particular-story.php?utm_source=abcwebsite.com&utm_medium=widget&utm_camp...

Google Analytics will automatically attribute the visit source to be the referring website, the visit medium to your widget, and the campaign of the visit to your widget tracking efforts.

You can use the URL builder reference I have attached to get the tweak the name of the source, medium, and campaign.
Remember that the naming convention is key because when you look at reports custom names should make sense.

Re: Can specific URL parameters be filtered/tracked?

[ Edited ]
Top Contributor
# 3
Top Contributor

Hi,

 

it is generally good practice to grab URL parameters from the URL (or using Google Tag Manager) and insert said variable value in a custom dimension.

 

 

If you use "vanilla" Google Universal tracking code, try the following:

<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','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXX-Y', 'auto');
  var urlParams= new URLSearchParams(document.location.search);
  var myParam = urlParams.get("value1"); // grabs value of URL parameter "value1"
  ga('send', 'pageview',{
    'dimension1': myParam // stores param in custom dimension #1
  });

</script>
VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan

Can specific URL parameters be filtered/tracked?

Top Contributor
# 4
Top Contributor

Follow-up:

to avoid generating multiple URLs, make sure to exclude the parameter in your view settings

 

VP & Chief Evangelist at Hub'Scan | Contact me
Level 80 Digital Analytics Warrior, KPI Therapist and Keeper of the One True Tagging Plan