Tracking File Downloads with Google Analytics - google-analytics

I have an html file that gets loaded when a user connects a flash drive to their PC. That HTML contains a direct link to a PDF on our server. (They don't want to put the PDF on the drive for some reason) Anyway, I'm trying to figure out how to track how many times this PDF is accessed from one of these drives.
Since the user is being taken directly to the file and not a landing page, is there a way I can attach analytics to the link that directs the user to the file? I was thinking a Virtual Page View would work but I don't understand exactly how GA would be getting that data.
Can anyone help demystify this?

GA needs to run javascript. PDFs will not invoke a call to GA when hit directly from search results, emails, or flash drives.
You might be able to track it by creating a rewrite rule on your server to a page that runs the GA code then loads the PDF on that page.
I had a similar feature on my site and it worked well except that while tracking the PDFs, the page that loaded the PDF was inflating my pageviews numbers. I didn't want PDF's to be mixed in with pageviews because it confused the client who had been used to separating the two. I created a filter for the PDF 'calling' page and the pageview number settled back down.
I ended up removing this method and falling back to the server logs for PDF downloads and GA for everything else.
GA is a javascript tracker. Plain and simple.

The issue is not the JavaScript, since you can include that locally, but the fact that GA won't work on HTML loaded from a filesystem.
The landing page can be built so that it automatically triggers the download and GA while that happens. Pageviews won't be an issue, since downloads should be tracked as events anyway.

You can attach a javascript function to the link and have it track the page view with Google Analytics
Check this out for more.
It's an easy way to track any file download on a website.

Related

How to track a PDF view (not click) on my website using Google Tag Manager

How can I track that someone visited the following URL of my website http://www.website.com/mypdf.pdf.
I tried using a Page View trigger on a Page View tag. I'm completely new at Google Analytics so not sure how to proceed. Most people are going to be going to that pdf directly via URL, as there is no link to it on my website, but I really want to be able to track how many people view it.
Thanks in advance!
You cannot track PDF views with the help of GTM. GTM for web is a javascript injector, and one cannot inject Javascript into a PDF document from the browser.
One way to circumvent this is to have a gateway page, i.e. have the click go to a HTML page that counts the view before redirecting to the document in question (naturally you could use GTM in that page). Since people go directly to the PDF URL this would require a bit of scripting - you would have to redirect all PDF links to your gateway page via a server directive, count the view and then have the page load the respective document.
Another even more roundabout way would be to parse your server log files and send PDF requests to GA via the measurement protocol (actually many servers allow to have log writes redirected to another script, so you could do this in realtime). I would not really recommend that approach - it's technologically interesting, but probably more effort than it is worth.
The short version is, if you are not comfortable fiddling a little with your server setup you will probably not be able to track pdf views. GTM does not work on PDF files.
Facing same issue…
My solution was to use url shortener (like bitly.com) which includes opening statistics.
Not the perfect solution but it works for direct pdf access from external source (outside your site).

Kentico Google Analytics page view

I'm looking at the GA traffic and I'm seeing page views for pages like this: /cms/getdoc/2d22c1db-ae83...angobjectlifetime=request
Is this page used when a user is viewing a document (PDF, Word, etc.)?
Not necessary. It could be any page within the content tree (including files). The cms prefix means it requires authentication (it's usually within the administration interface) and the getdoc handler means the url is permanent one (uses the GUID that follows), so you always get this page/file no matter where in the content tree it is (after you move it for example)
Google Analytics records anything hit to your website which is used to access either to access a legitimate page or used to access a resource on your website. You should use filters during report to filter out this data.

Google Analytics Receiving Data -- but no analytics in view source

My client created a website and a google analytics account. The report indicates that the account is receiving data -- and yet, when we do a view-source of the pages of the site, there is definitely absolutely no analytics code there. How is this posssible?
It is possible that the Analytics code is added via Javascript, not appearing in the "View Source" page. It is also possible for it not to appear in the inspector either.
I do not know how this happens, but I have encountered scripts that exist and run although they are not displayed in either the source page or the live DOM inspector (in Google Chrome). This happened to me while loading a PHP template containing Javascript through an Ajax request.
If you have access to the source code of your website, search the entire project for for the Analytics ID (Here's how to find it: https://support.google.com/analytics/answer/1032385?hl=en), and you'll locate your tracking code.
If your project is running on a Linux server, here's a post about how to quickly find a keyword (like the Analytics ID) in a folder: How do I find all files containing specific text on Linux?

How to track download content

I have a requirement where I need to track the event of mostly downloaded pdfs/zip file from AEM. So for that I was thinking about two ways -
1) Use Adobe analytics and track the download event. After I will write a component in AEM to query Adobe analytic to give the result. But I could not find document on how to query analytics data from Adobe AEM.
2) Use tracker.js. But when I hit this url then this url host:port/libs/wcm/stats/tracker.js?path=/content/dam/geometrixx/documents/GeoCube_Datasheet.pdf then it says "impression added" but there is no way to see impression in console. Where I can see the impression? Is tracker.js only for page tracking?
For the Google Analytics I would go with an event trigger (or a virtual pageview if you prefer that). see https://support.google.com/analytics/answer/1136922?hl=en-GB
in both cases you will be able to track it (and see it happening in the debug console).

Google Analytics - tracking somePage.exe pages

If I have my server setup to serve up pages with .exe extension as html content, and I put standard GA tracking code (javascript) onto my page, will GA reject hits to that page, since it's a .exe extension?
I am asking because .exe files are traditionally tracked as downloads by tracking tools...
...so has anybody had experience with putting GA on .exe files served up as web pages?
If the .exe renders HTML and executes the GA tracking code, then it should appear in your Content Reports after the customary 24-48 hrs. Unsure if there are any restrictions for .exe files on the GA side (I would venture that there aren't any), but give it a try in a test profile and see what you get.
HTH,
KM

Resources