OK, here's a goal I've been looking for a while.
As it's known, most advertising and analytics companies use a so called "pixel" code in order to track websites views, transactions, conversion etc.
I do have a general idea on how it works, the problem is how to implement it. The tracking codes consist from few parts.
The tracking code itself. This is the code that the users inserts on his webpage in the
<head>
section. The main goal of this code is to set some customer specific variables and to call the*.js
file.*.js
file. This file holds all the magic of CRUD (create/read/update/delete) cookies, track user's events and interaction with the webpage.The pixel code. This is an
<img>
tag with thesrc
atribute pointing to an image*.gif
(for example) file that takes all the parameters collected on the page, and stores them in the database.
Example:
WordPress pixel code: <img id="wpstats" src="http://stats.wordpress.com/g.gif?host=www.hostname.com&list_of_cookies_value_pairs;" alt="">
Google Analitycs:
http://www.google-analytics.com/__utm.gif?utmwv=4&utmn=769876874&etc
Now, it's obvious that the *.gif
request has to reach a server side scripting language in order to read the parameters data and store them in a db.
Does anyone have an idea how to implement this in Zend?
UPDATE
Another thing I'm interested in is: How to avoid the user's browser to load the cached *.gif
? Will a random parameter value do the trick? Example: src="pixel.gif?nocache=random_number"
where the nocache
parameter value will be different on every request.
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
– Hammons