adswerve / universal-analytics-php

Universal Analytics library for PHP
http://www.analyticspros.com/tools/code/
BSD 3-Clause "New" or "Revised" License
48 stars 21 forks source link

Document Flush #5

Closed ikanor closed 10 years ago

ikanor commented 10 years ago

First thing I did when trying out the library was to send a couple of events using PHP's CLI. To my surprise, the events did not appear instantly in my real-time console of GA. This brief message might prevent subsequent developers from spending a few minutes trying to figure out what's wrong with their events.

samba commented 10 years ago

Thanks @ikanor.

That buffering feature has been the source of more confusion than I had expected. Its purpose was to improve network performance for tracking, by allowing CURL to pipeline the requests.

I think a Tracker.flush() shortcut would be desirable, as well as more readily disabling the buffering behavior altogether.

One developer went so far as to completely rewrite the request logic to push it directly onto their own socket, bypassing CURL entirely, and completely ignoring GA's response. Because GA's HTTP response doesn't indicate validation of the actual tracking requests anyway, this approach may have some merit.

I'd happily consider alternatives if you'd suggest any.