Google Analytics tracking code is pasted into a pdf file

Is it possible that I can embed Google analytics tracking code in a PDF file? I want to know where users come from and how users behave in my PDF file.

Please help me if you know some kind of process or approach ...

I know that PDF accepts some javascript, but I don't know if it is capable of parsing Google.

Thanks!

+3
javascript pdf google-analytics
source share
3 answers

You cannot, as far as I know, insert the actual snippet of Google Analytics JavaScript code into a PDF.

EDIT . My previous answer was wrong; I said you can insert __utm.gif , which launches GA in PDF, but @Mark correctly says that this is not possible.

The correct answer: it is impossible to embed an external resource into a PDF, at least not with modern PDF readers with basic security settings.

+2
source share

It just won't work. The PDF object model is completely different from the HTML DOM. Scripts in one will not work in the other without using different null references:

 var foo = document.getElementByID("someID"); 

"Boom: document is undefined" , like the "window", and all other global object web pages are dependent on.

+1
source share

Personally, I put the PDF inside the iframe, and then put GA and Piwik in the header of the html page containing the iframe. A little crooked, but does the job.

0
source share

All Articles