How to Integrate Google Analytics with Your CRM for Better Content Analysis

The Value in Integrations

Firstly, it’s important to know why you’d want to integrate Google Analytics with your CRM or lead management tool.

Closing Your Data Gap

In most cases, integrating Google Analytics with your CRM isn’t a simple process. But there is a workaround. And it involves Google’s ability to generate a unique but anonymised ID.

Integration Guidelines

This solution is great for online services like ecommerce sites, where users are required to log in to your site first. Once they do this, you can capture their User ID and pass it into Google Analytics with a custom JavaScript snippet, using cookies or the DataLayer.

  • Get your developer to push the UserID to the DataLayer. It’s probably the most stable way. Once the UID is in the DataLayer, you can create a DataLayer Variable in Google Tag Manager to push to Google Analytics. Make sure you use the same name for the variable and the UserID in Google Analytics.
  • Pass the UserID in a cookie. This can be done through the DataLayer or by the developer using some custom JavaScript. The cool thing about storing the UserID in a cookie is you can persist the session even after a user closes the site (as long as they don’t clear their cookies). This way, even if the user hasn’t logged back into your site but is on it, you can still connect that session to that user in your CRM. There is a great article by Simo Ahava on this here.
  • Use a JavaScript variable without a cookie. In this way, the UID is passed into Google Tag Manager using a Custom JavaScript variable, which can then be sent to Google Analytics.
  • Scrape the DOM (Document Object Model). This risky (and not recommended) method of capturing a UID requires it to be displayed on the website as, say, a text element. You then ‘scrape’ this content from the page and assign it to a variable in Google Tag Manager, which then passes it to Google Analytics. Please note: This can be a flaky process and it’s prone to errors.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Marketing automation software that enables data-driven and hyper-personalised communication via email and SMS.