Question from user:
Hi guys, I’m interested in adding information from Google Analytics to Salesforce, but most of the native integrations seem to require Pardot.
I’ve found some third-party connectors but they don’t seem very appealing to me.
Specifically, I want to add some of the source/medium data to our opportunities and campaigns based on an external ID generated by our ERP that is passed to both GA and SF. It doesn’t need to be realtime, but a daily or weekly sync would meet our requirements. Anyone have any experience with this?
Answer from Nabil:
That is a really interesting challenge, and you are right that many out-of-the-box solutions lean heavily on Pardot or Marketing Cloud.
Given your specific requirement to use an external ID generated by your ERP that is already present in both Salesforce and Google Analytics, a custom integration built around the Salesforce API, the Google Analytics Data API (GA4), and Google Tag Manager (GTM) is likely your best and most flexible solution without resorting to third-party connectors you do not like.
The core idea is to join the data in the middle using that common ERP ID.
The first step involves capturing that external ERP ID reliably in Google Analytics.
You can use GTM to push the ERP ID into Google Analytics as a custom dimension on the hit, session, or user level, depending on how it relates to the user’s journey, which gives you the key to unlock the data.
You would do this by setting the ERP ID into a data layer variable when the user lands on the page and then mapping it to a custom dimension within your GA4 configuration tag.
Because you are tracking opportunities and campaigns, it might make sense to also fire a custom event in GA4 when a conversion or key action happens and include the ERP ID and any other relevant data as event parameters.
The second step is the data retrieval and synchronization.
This is where the Salesforce API and the Google Analytics Data API come into play, orchestrated by an intermediate tool like a serverless function on Google Cloud Platform (GCP) or a similar service.
A service like Stape, which offers server-side tracking, can also be used to enhance the quality of your data capture, but the main sync logic will reside elsewhere.
Your synchronization script would run daily or weekly, as needed.
First, it would use the Google Analytics Data API to query your GA4 data, filtering for the desired source/medium information, and critically, including that custom dimension that holds your ERP ID.
The query would give you a list of ERP IDs and their associated GA data.
Finally, the script would use the Salesforce API to perform the updates.
You would take the list of ERP IDs from your GA data and use them to find the corresponding records – Opportunities, Campaigns, or a custom object – in Salesforce.
Once the records are identified, the script would use the Salesforce API to update the fields on those records with the source/medium data you retrieved from GA4.
This approach is powerful because it uses the native APIs of both systems and relies on your unique ERP ID for a high-fidelity match, ensuring you have the granular data you need without relying on a full-suite marketing automation product.