0
votes

I want to track vanity url in which PDF is present in GA.

For e.g. I have vanity url

xyz.com/study when user click a url opens.

Click of vanity url opens a page in PDF format.

below is the url. http://example.com/sites/default/files /course.pdf?utm_source=vanityurl&utm_medium=email&utm_campaign=pdf%20tracking. I want to track utm parameter in GA

Can any one suggest hot to do that in GA or using Google Tag Manager

1

1 Answers

0
votes

I believe you have 2 options based on how this vanity URL actually functions:

1 = If the vanity URL is always accessed by clicking a link, you could write an onclick function for all links to the URL which fires a virtual pageview and sets the source, campaign and medium. something like this:

<script>
function trackpdf(){
  ga('set', 'campaignName', 'pdf tracking');
  ga('set', 'campaignSource', 'vanity url');
  ga('set', 'campaignMedium', 'email');
  ga('set', 'location', 'http://example.com/study');
  ga('send', 'pageview')
}
</script>
<a href="http://example.com/study" onclick="trackpdf();">view pdf</a>

2 = If the vanity URL has some server side code sat behind it, you could use the measurement protocol to send a pageview. This would mean creating a valid GA HTTP request and sending it using server side code. Check out the Google Docs for more info.