1

I followed these instructions to use Google Tag Manager to track PDF downloads without having to manually add an onClick to every PDF link on our site and it is now tracking PDF downloads reliably. However, our PDFs are stored on a static asset server, not on the Drupal server, so each PDF download is also an exit. In the analytics, PDF downloads are showing up as relative to the root of the Drupal server: instead of

http://staticserver/file.pdf

they show up as

http://mainserver/http://staticserver/file.pdf

Step 5 in the howto linked above doesn't appear to address this issue (or else I'm mis-reading it). How can I get analytics to recognize that these clicks lead to a different host and are not relative to the root of the main server?

1

In GA reports, your homepage will probably be '/', and 'www.mysite.com/page1' will come out as '/page1'.

This is because Google Analytics usually keeps the primary domain in a different dimension, 'Hostname'.

The issue here is that you're sending the Page View from one domain, and claiming that it comes from another.

In a similar manner to the 'page' and 'title' fields, you can edit the 'hostname' field in the Fields to Set area of GTM.

| improve this answer | |
  • Ah, OK. After adding {{Page Hostname}} to the fields to set, looking at realtime->content, I can see now that the main server is no longer showing up in the report. However, the leading slash is. Instead of http://mainserver/http://staticserver/file.pdf, it shows /http://staticserver/file.pdf. Like you said, / is the root of the main server. Do you know of a smarter way to track PDF clicks that go to another host? The examples I've found seem to be for PDFs on the same host. – Riblet Jul 25 '16 at 16:19
  • Are you appending anything to the page path before sending to Google Analytics? – J Brazier Jul 25 '16 at 16:21
  • I don't believe so. It's just a UA tag with click text, click URL, and now page hostname, enabled on all pages, firing when the click URL matches \.pdf$. – Riblet Jul 25 '16 at 16:24
  • The smarter way to do this is to split the click URL into path and hostname before you feed that information to GA. – J Brazier Jul 26 '16 at 9:27
  • The page has native variables for hostname and path, but click only seems to have a unitary variable for ClickURL. Presumably I can put some custom code in to parse ClickURL into the two variables - where would I put that? What would I need to do to ensure that GA receives and understands what the values I'm passing it mean? – Riblet Jul 26 '16 at 15:54

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.