Tracking ecommerce subscriptions through Google Analytics & PHP


Staff member
I have a site that has a monthly subscription.

I would like to use Google Analytics to record these transactions. That's easy to do with their ecommerce functions, but my transactions are monthly. I could just say that each sale is worth the average I expect to make, but then I won't get useful statistics like "people from country x are more likely to cancel their subscription after the 2nd month", or "people over 45 continue the subscription for an average 3x longer than people under 45", etc.

So what I need is a way to retrieve and store Google's ID of the user and then push purchases to Google Analytics from server side, which Analytics would then count as a recurring purchase by that person.

I found this article that looks like its explaining what I want to do:
<a href="" rel="nofollow"></a>
However it's not completely clear. It seems to me that this is not going to match then up with the country, gender, age group, etc. and all the other data that Google has on that person.

So if I get the Google Analytics cookie of the user with:

function gaParseCookie() {
  if (isset($_COOKIE['_ga'])) {
    list($version,$domainDepth, $cid1, $cid2) = split('[\.]', $_COOKIE["_ga"],4);
    $contents = array('version' =&gt; $version, 'domainDepth' =&gt; $domainDepth, 'cid' =&gt; $cid1.'.'.$cid2);
    $cid = $contents['cid'];
  else return false;
  return $cid;

Then I can just store this and later use it to push the recurring purchase server-side to Google? And that will give me all the metrics with demographics and everything already discovered about this user to plot against the sales value?