Reputation: 10325
I'm using the following:
I'm using wordpress action hooks that the plugin provides to use the ss-ga class that triggers a page hit for the XML Feed (iTunes needs this) and event for the podcast play (download):
ssp_file_download
and ssp_before_feed
That all works great. I'm using cloudflare, so I can use $_SERVER['REMOTE_ADDR']
OR $_SERVER["HTTP_CF_CONNECTING_IP"]
to get the client IP. The problem, is that with ss-ga, I cannot send the client IP when registering the event or page hit. As a result, it always shows Chicago, which is where my host's data center is.
Can someone suggest a way to make sure that when I send an analytics event using a php class, that the IP is correct?
Thanks in advance. If you want any code, just let me know but I've used basic examples as provided by both script's documentation.
Cheers.
Upvotes: 0
Views: 905
Reputation: 32760
By far the best way would be not the ss-ga class and instead use the measurement protocol. The measurement protocol is not only the way Google Analytics should be implemented these days, it also offers a parameter &uip
to send an users IP along. There are various packages that implement the measurement protocol in PHP classes, so it should't be harder to use than ss-ga (in fact it's most probably simpler, more reliable and better documented since it is specifially built to provide a language agnostic interface to GA).
Upvotes: 1
Reputation: 90776
What you could try if to generate the GIF URL using getFullBeaconUrl()
, then request this GIF via Curl, and set the IP to the user's IP. Something like that should work:
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $gifUrl);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: $ip", "HTTP_X_FORWARDED_FOR: $ip"));
Upvotes: 0