Import GA information to Salesforce – Part 1, The Problem

The Question

A question on stackoverflow asked “how Intergrate (sic) google adwords tracking with salesforce“. Specifically the question was to get campaign source, medium and campaign name for people who had filled in a web form that sent data to SF.

The question used an approach that is doomed with the current Incarnation of Google tracking, Universal Analytics. In previous versions of GA campaign information was evaluated on the client side and stored into a cookie before it was sent to the tracking server.  Universal Analytics does not do that; it uses a single cookie that stores the client id, which is used to aggregate pageviews into sessions and sessions into users. There is no need to store the campaign info on the client side since Universal Analytics can simply look back at the landing page of a session for a given client id and deduce the campaign information from there. So you cannot pull those values into a web form via JavaScript anymore.

Additionally even with the previous version of GA this approach would not resolve campaign information from Google Adwords campaigns with autotagging enabled. Autotagging would use a single parameter (Google click id, or gclid) for campaign information that would be resolved into campaign information only if GA was linked to the respective Adwords account.

However there is no need to collect this information in realtime via a webform. You can set up the form that posts information to Salesforce (Web to Lead) and include a field that includes an custom id; the same id is sent with an event tracking call as a custom dimension to Google Analytics. Later you can export campaign information from Google Analytics and insert it into custom fields that you previously have set up in Salesforce. Not only this does work without campaign information from cookies, GA will also resolve the Adwords glcid into human readable source/medium/campaign names.

The possible disadvantages are that you do not have the data in realtime (you need to allow for processing time in Google Analytics, up to 24 hours), and that you need to run a serverside program once in preset intervals to copy the data from one application to the other.

So further down the line this tutorial will include some  Python code, so I will use the next installment to give a (very basic, I hasten to say – this is supposed to be very much a beginners tutorial) introduction to Python and the general programming environment I will use in this tutorial.

Tutorial Table of Contents

Leave a Reply

Your email address will not be published. Required fields are marked *