admin管理员组文章数量:1391981
Is it possible that I can insert a tracking code of Google analytics in PDF file? I want to know where are users ing 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!
Is it possible that I can insert a tracking code of Google analytics in PDF file? I want to know where are users ing 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!
Share Improve this question asked May 22, 2011 at 21:17 Pennf0lioPennf0lio 3,8948 gold badges48 silver badges74 bronze badges3 Answers
Reset to default 2You 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.
That simply isn't going to work. PDF's object model is pletely 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.
Personally I place the PDF inside an iframe and then I place my GA and Piwik in the header of the html page that contains the iframe. A bit crooked, but does the job.
本文标签: javascriptGoogle analytics tracking code insert in pdf fileStack Overflow
版权声明:本文标题:javascript - Google analytics tracking code insert in pdf file - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744667475a2618620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论