[英]How to implement a Tracking Pixel that counts the Page Views?
I want to implement a tracking pixel in my pages and email like this: 我想在我的页面和电子邮件中实现一个跟踪像素,如下所示:
<img src="someurl/tracking.js">
What do I have to write in my tracking.js in order to get the code executed? 为了执行代码,我必须在tracking.js中编写什么? Can I use JQuery inside this code? 我可以在此代码内使用JQuery吗?
I found the answer in this blog post: http://grooovygeorge.wordpress.com/2012/12/13/serving-a-blind-gif-from-a-string-in-grails/ 我在此博客文章中找到了答案: http : //grooovygeorge.wordpress.com/2012/12/13/serving-a-blind-gif-from-a-string-in-grails/
import org.springframework.security.core.codec.Base64
class TrackingController {
private static final String PIXEL_B64 = "R0lGODlhAQABAPAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
private static final byte[] PIXEL_BYTES = Base64.decode(PIXEL_B64.getBytes())
def track() {
// track the request here...
// send the GIF image
response.setContentType("image/gif")
response.outputStream << PIXEL_BYTES
return // this statement is required.
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.