AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

2.1K members online now
2.1K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Sending data to Analytics from php

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've come far with sending PayPal data into Ecommerce Analytics.


But the final piece of the puzzle is still missing: How do I inject data into Analytics from a server-side script rather than javascript?


My data flow is as follows:

1) Website javascript fetches clientId according to

2) Website merges clientId and some other meta data into PayPal's variable "item_number" associated with a Pay Now button (see details below)

3) After purchase is completed, PayPal calls my IPN script (php) which extracts clientId etc. from "item_number"

4) The IPN script is then able to put together a nice piece of javascript which calls ga() with all the right data

5) But how to execute that javascript?

6) Or how to put the same data into Ecommerce Analytics without javascript?


This is as far as it comes. The IPN script puts together all the nice javascript code, but it is essentially a server-side script with a lot of curl commands. It isn't executed on a javascript engine.


So I'm essentially looking for a way to inject the transaction's data now available on the server side into Analytics without running a browser.


(PayPal variable detail: I use a Pay Now button. Then "custom" is not available as a pass-through variable. See )





Re: Sending data to Analytics from php

Participant ✭ ✭ ☆
# 2
Participant ✭ ✭ ☆
You can use Measurement Protocol to send data to GA using PHP.
Here is some more info:
And a hit builder tool to make some tests:

Re: Sending data to Analytics from php

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks Tomasz!

Looks like I've got a bit of reading to do :-)