Embed analytics code within image to be triggered when image is displayed -


is possible pack analytics code within image , have code fire when image loaded on webpage?

the image inserted onto page through file upload form field such if add image question have no direct access add html or js page.

goal being track page views on pages have no access code, ability upload image.

almost kind of 'trojan horse' approach without malicious intent.

tracking pixels requires specific structure , specific server.

so cannot imagine trojan horse, can track image load event.

try this:

single purpose client side

<img src="" alt="facebook new god" id="fblogo"/>  <script type="text/javascript">     window.onload = function () {         var logo = document.getelementbyid('fblogo');         logo.onload = function () {             ga('send', 'event', 'fb', 'loaded');               };          logo.src = 'https://facebook.com/fb/logo.png';     }; </script> 

measurement protocol way - server side

https://www.google-analytics.com/collect  ?v=1                                    // protokol version &tid=ua-xxxx-y                          // property id &cid=55568765456                        // client id stored in database or random number   &dh=forum.eu                            // referrer &dp=image78974.png                      // filename  &t=event                                // send instruction  &ni=1                                   // non inteaction flag &ec=image                               // event category &ea=load                                // event action &el=image78974.png                      // event label 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -