Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tracking pixel or javascript include?

I am building a tracking system for refererrals to our websites and on behalf of other 3rd party website owners. This will include placing a cookie when a customer clicks through to the site and subseqently reading their ID from this cookie if they reach the defined 'success' page.

I have seen a number of different methods used for tracking and they all seem to fall into 2 categories:

  1. Including an IMG tag which will link to a script that processes what it needs to and returns an image

  2. Including an external javascript file, usually with the same approach as in 1 within tags.

What are the benefits of one approach over the other? I feel I must be missing something quite simple here however can only see that the javascript approach can be used to avoid image caching.

The server-side script is ASP.net

EDIT: The cookie / tracking approach is being used because it seems to be the industry standard, and we need to be able to track goals over a long period of time and / or many visits however alternatvies to this approach would be welcomed!

Thanks

like image 974
Macros Avatar asked Jun 15 '09 15:06

Macros


2 Answers

If you include an external script in the <head> section, it is downloaded and executed before the page is shown, so you are sure that if a user saw the page they got tracked. For <img> tags there is no such guarantee, as the user might navigate away before the browser launches the load request for that image.

So, if you want to optimize for trackability, use a <script>, but if you want to optimize for performance (no slowdown if the tracking site is slow), use an <img>.

The caching issue exists in both cases, and can be solved by sending correct headers from the server or by appending cache-busting arguments to the URL.

like image 120
Joeri Sebrechts Avatar answered Sep 28 '22 17:09

Joeri Sebrechts


It's worth noting that many tracking software pieces like Google Analytics utilize 1x1 pixels. If you are trying to avoid caching you can set the cache expiration on the particular page so that content will not be cached on the user end. As it stands though you really just need the cookie to be set the one time and if the user has not cleared their cache on subsequent visits chances are they haven't cleared their cookies either.

You can use either method and expect that there will be some small percentage of users that monitor cookies or scripts and will try to avoid having your cookie set on their machine. Almost no one browses with images disabled.

Those users who fall into that minority of people who are paranoid about cookies and/or javascript will not generally affect your tracking information overall unless of course your site specializes in serving content to that demographic (highly technical users etc). So, I wouldn't go overboard on tailoring your solution for that minority unless absolutely necessary.

like image 42
Harv Avatar answered Sep 28 '22 18:09

Harv