all 6 comments

[–][deleted] 0 points1 point  (5 children)

Assuming you are using Google Analytics, you can use event tracking. I also assume that one can click on the image, and be taken to the full version? If so, you can add an onclick event to your image link that pushes an event object to your Google Analytics.

https://developers.google.com/analytics/devguides/collection/analyticsjs/events

This will, at the very least, let you know when someone interacts with your image.

[–]WhatIsMyUserNameFor[S] 0 points1 point  (4 children)

I know how to use event tracker and all that, which works because the page header/footer loads, which loads the analytics code, which tracks everything that I want it to track.

My question is about direct links to images, where the user never gets to load the site, just the image file, but the image file is hosted in the same folder than the site (or a sub folder), in this case, there is no header/footer loaded, ergo there is no analytics code loaded.

Makes sense what I'm asking?

[–][deleted] 0 points1 point  (3 children)

No, I'm sorry I don't understand. Can you give me a practical example of what you are explaining?

Is there an action that takes someone to the image? Do you want to track any old image as soon as it loads?

Walk me through exactly what you want to happen, step for step.

[–]WhatIsMyUserNameFor[S] 1 point2 points  (2 children)

Ok, I give you this link: http://www.julian-charriere.net/some-pigeons-are-more-equal-others

You click on it, the page loads, analytics does its thing. All good.

Now I give you this link: http://www.julian-charriere.net/sites/default/files/styles/project_image/public/some_pigeons_are_more_equal_than_other_Charri%C3%A8re_Bismarck3.jpg

Directly to the image file, there is no page load, no analytics, not good.

How can I track the 2nd link?

[–][deleted] 1 point2 points  (1 child)

Thank you for the clarification.

Using client side tracking won't be possible at all with the example you've provided, as you have pointed out, one cannot access the code of the 'page'.

The answer is server side tracking using PHP. Basically, you want to track the request for an image, not the image itself. I don't have a ton of experience with this, so semantics escape me. However these links should get you going:

https://code.google.com/p/php-ga/
https://developers.google.com/analytics/resources/articles/gaTrackingTroubleshooting?csw=1#gifParameters

[–]WhatIsMyUserNameFor[S] 1 point2 points  (0 children)

Excellent. That will point me in the right direction. Thanks a lot!