Extracting variables for CRM Integration with universal analytics

1,501 views
Skip to first unread message

Andrew Clark

unread,
Dec 9, 2013, 7:49:51 PM12/9/13
to google-analytics...@googlegroups.com
Hi everyone, I'm hoping that someone can point me in the right direction to answer my query regarding CRM integration with Universal Analytics. 

Our Current Process

A visitor comes to our website and we use Justin Cutroni's approach to merge our data with our CRM, this involves us using a custom variable to accept the visitor id (which I believe is now the Customer ID in UA) that is associated to the visitor. We then use the Google Analytics API to pull in the associated campaign, source, medium etc. data that is tied to that visitor id to complete the picture within our internal marketing reports. This allows us to calculate all of the financial and campaign performance data we need at the sale level, rather than at the lead level that G.A gives us (since our visitors aren't buying online).

The New Process?

We don't currently have a way to identify users across devices at this point in time (the sites are being upgraded to feature a customer area) so the UID is not relevant to us at this point in time. However, the Google I/O video that I recently watched noted that we can use the client ID / CID in place of the visitor ID. This is fine and I have seen the example of how to extract this from the token and pass it to the CRM. My question is however, how do I now get my marketing performance data out of GA against these CID's? I looked in the Google API query explorer but I couldn't see any dimensions called CID or UID. Do I still need to pass back the CID to GA as a custom varaible so it can extract it from GA (as per the current approach)? If so, that seems a little redundant since GA is already setting the variable for us. If I do need to pass it back, do I simply use the GA measurement protocol to perform this task (once I set up the dimension in the GA admin?)

Thanks so much for your help. I really appreciate any assistance that can be provided.



Pete

unread,
Dec 10, 2013, 10:53:50 AM12/10/13
to google-analytics...@googlegroups.com
What you've written is correct. Currently there is no way to query for a Client or User ID. You can use the Issue Tracker to add a feature request to expose these IDs as dimensions in the Core Reporting API.

Aaron Toledo

unread,
Dec 10, 2013, 11:04:43 AM12/10/13
to google-analytics...@googlegroups.com
I believe you can use the CID in conjunction with the UID. My understanding is that, if you want to use Google's CID, you can retrieve it using the 'get' command (https://developers.google.com/analytics/devguides/collection/analyticsjs/domains). However, if you want to define a UID across devices, you'll have to get that value from one of your other systems and then pass that to Google. This UID could be coming from your own client data warehouse because you're building a customer area where they can log in and authenticate themselves. In this scenario, you can send that UID to Google using the Measurement Protocol or by defining it with 'set' prior to sending the pageview with a page. 


On Monday, December 9, 2013 4:49:51 PM UTC-8, Andrew Clark wrote:

Andrew Clark

unread,
Dec 11, 2013, 3:31:49 AM12/11/13
to google-analytics...@googlegroups.com


Just adding this in case someone stumbles upon my question via search:

Success!

Here is the code as it stands:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
 
  ga('create', 'UA-XXXXXXX-YY', 'domain.com');
  ga('send', 'pageview');
 
  var clientId = "";
  ga(function(tracker) {
  clientId = tracker.get('clientId');
  ga('send', 'pageview', {
  'dimension1': clientId
  });
  $('#clientid').val(clientId);
  });
 
</script>

Obviously UA-XXXXXXX-YY and domain.com need to be customised, as does 'dimension1' but with the basic jQuery library on the page we were also able to pass back the clientId to a hidden form field - that's what the "$('#clientid').val(clientId);" part is doing - the form field name is specified after the hash/pound (#) symbol.

Thanks again for everyone's help!

Aaron Toledo

unread,
Dec 11, 2013, 9:25:19 PM12/11/13
to google-analytics...@googlegroups.com
Out of curiosity, couldn't you also just define the custom dimension within the first pageview call? Or is it required that you make a second pageview call for this to work? 

Andrew Clark

unread,
Dec 11, 2013, 10:51:27 PM12/11/13
to google-analytics...@googlegroups.com
It doesn't work when moved up into the first call, but you're right, that call can be removed leaving:

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-1797073-14', 'homebuyers.com.au');

 
  var clientId = "";
  ga(function(tracker) {
  clientId = tracker.get('clientId');
  $('#clientid').val(clientId);

     ga('send', 'pageview', {
  'dimension1': clientId
  });
  });

</script>


--
You received this message because you are subscribed to a topic in the Google Groups "Google Analytics Reporting API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-analytics-data-export-api/l7-b5FoyW5Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-analytics-data-...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Michael Lommel

unread,
Jan 12, 2015, 10:25:09 AM1/12/15
to google-analytics...@googlegroups.com
Thanks, Andrew,  for posting this code; helpful to see a real world example and gives me new ideas of how to work with GA.

Are you then in your CRM successfully pulling ClientID-associated data from GA into the CRM? Doesn't ClientId still possibly end up a single person as multiple people over time?

To unsubscribe from this group and all its topics, send an email to google-analytics-data-export-api+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages