Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google analytics tracking code insert in pdf file

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

Please do guide me if you know some process or approach...

I know that PDF accepts some javascript, but I don't know if its capable of google analytics.

Thanks!

like image 870
Pennf0lio Avatar asked Oct 20 '25 16:10

Pennf0lio


2 Answers

You can't, to my knowledge, insert the actual Google Analytics JavaScript snippet into a PDF.

EDIT: My previous answer was incorrect; I said you could embed the __utm.gif that GA fires in the PDF, but @Mark is correct in saying this is not possible.

The correct answer is: It's not possible to embed an external resource in a PDF, at least not with modern PDF readers with basic security settings.

like image 164
Yahel Avatar answered Oct 23 '25 07:10

Yahel


That simply isn't going to work. PDF's object model is completely different from HTML's DOM. Scripts in one won't work in the other, failing with various null references:

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

"Boom: document is undefined", as is "window" and all the other global objects web pages depend on.

like image 39
Mark Storer Avatar answered Oct 23 '25 05:10

Mark Storer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!