Google Analytics User ID Setup for Infusionsoft

KB2014011

If you're using our AnalyticsConnect.io software that automatically posts sales data from Infusionsoft into Google Analytics Ecommerce, you may be wondering how to send the Infusionsoft Contact ID into Google Analytics as a User ID. This knowledgebase article will explain the functionality added by doing this and walk you through the installation process.

Please note: This is a very complex custom configuration. If you are not a Google Analytics expert, you can purchase one of our paid support packages for help setting this up.

Functionality Added

We live in a world where many of the visitors to our website have multiple devices, such as a smart-phone, tablet, office computer, and home computer. This creates a tracking nightmare. What if a user clicks on one of our AdWords ads from their tablet and signs up for our newsletter, but then places an order a week later from their office computer? If we don't have a way to link those sessions together, we don't know that AdWords was responsible for finding that customer, and thus our return on ad investment calculations are wrong.

Google's answer for this inside Google Analytics is to send the optional parameter uid, which is User ID. When separate devices and/or sessions have the same unique uid, Google Analytics knows to link them together as the same user. For those of us running Infusionsoft, we already have a unique identifier for each contact, called Contact ID. When you have this optional feature enabled for Google Analytics inside of your settings for AnalyticsConnect.io, AnalyticsConnect.io will send the corresponding Contact ID from inside Infusionsoft, with the transaction data, into Google Analytics as uid.

Setup

Beyond turning this feature on inside of your settings page, there's some other configuration that will need to be done. First, you'll need to turn this on inside Google Analytics. Sign in to your Google Analytics account, and go to the "Admin" page. Select the account from the dropdown in the "Account" column. Select the property from the dropdown in the "Property" column. Click on "Tracking Info" and then on "User Id" and follow the instructions listed. We recommend naming your new view (as the instructions tell you to create) "All User-ID Data" and that you do NOT add any other filters to this view. If you want to add additional filters to your User ID view, simply create another new view named "User-ID Data (Filtered)" and add the filters to that view.

Next, you will need to modify all Google Analytics tracking code. If you are using our WordPress Plugin you will have to disable it from writing Google Analytics tracking code. Un-check the box inside of the WordPress Plugin Admin that says, "Write Google Analytics Tracking Code". Unfortunately the User ID config is too complex to have our WordPress Plugin write the code for you. Using our cross-domain tracking example as the base code:

<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-XXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['example.com', 'aa100.infusionsoft.com'], false, true);
ga('send', 'pageview');
</script>

You'll have to make the following addition:

<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-XXXX-Y', 'auto', {'allowLinker': true, 'userId': '123456'});
ga('require', 'linker');
ga('linker:autoLink', ['example.com', 'aa100.infusionsoft.com'], false, true);
ga('send', 'pageview');
</script>

In the above example code, we hardcoded uid to 123456 for ease of explanation, however this value will have to be populated dynamically for each user, for each page hit. To do this you're going to have to programmatically retrieve the Contact ID from Infusionsoft and insert it in that place. And remember, you'll only insert this red section of code if you have a User ID available. As an example, if you had a membership site that users log into, and that site was written in PHP, your code to add that section in may look like the following.

<?php if ($_SESSION['loggedin']) { echo ", 'userId': '" . $_SESSION['userid'] . "'"; ?>

It's important to understand that if you're going to enable the User ID inside Google Analytics, you have to be inserting it on all your pages. Otherwise a user may not interact with a page that sets the User ID, and in that case the session would never get linked to their other sessions.

Known Limitations

If you merge two duplicate contacts inside Infusionsoft, you're merging Contact IDs, and there is no way to merge User IDs with Google Analytics. You'll drop data for whatever Contact ID got dropped. Do everything you can to prevent duplicate contacts from being created inside Infusionsoft.

Access the Cross Device Reports

Once you have this setup, you'll have access to the Cross Device Reports inside Google Analytics. You can find the Cross Device reports in the Audience section of a User ID reporting view. These reports include Device Overlap (find out what type and how many devices are used to access your content), Device Paths (discover the last 5 device types used before a conversion), and Acquisition Device (see the relationship between acquisitions and conversions).

Related Resources

Integrating Google Analytics With Infusionsoft

Google Analytics Cross-Domain Tracking For Infusionsoft

Subscriptions and Multiple Payments

Article Feedback

If this article is incorrect or outdated, or omits critical information, please use our contact us form and let us know.