Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Analytics Measurement Protocol Returned Gif

I'm using the GA measurement protocol, and it's returning a gif file.

I'm a little unclear what this file is for - ideally I'd like to be able to send measurement protocol requests as fire and forgets to keep page load times at a minimum.

Is it important to render this gif on the page?

like image 903
Tom Gullen Avatar asked Apr 27 '17 14:04

Tom Gullen


1 Answers

That's simply a design decision by Google - calls to the GA endpoint return a 200 http status and a 1x1 transparent gif (regardless if your payload data is valid or not, so don't use that to ascertain if your hit has been recorded).

I presume a http 204 not content would have worked as well, but at least with the gif image you can stick you measurement protocol call into an image tag (as a tried and tested way to transmit data over domain boundaries from your domain to Google).

The browser needs to receive it know that the request is complete, but you do not need to render it.

like image 71
Eike Pierstorff Avatar answered Sep 21 '22 16:09

Eike Pierstorff