One of the most frustrating aspects about capturing conversion data is later attributing that conversion to an offline sale. So unless you have an integrated ecommerce platform or some point of sale checkout process, using Google Analytics and Google Ads to later map sales from conversions is pretty darn impossible.
Luckily, we can capture the Google Analytics Client IDÂ from our website’s visitors using Google Tag Manger and send them by email, a CRM such as HubSpot, or another storage destination and later import them to report as Offline Conversions.
I came across a guide from Mixed Analytics that gave me the code I needed, shout out to them and thanks!
Watch the video version of this tutorial on YouTube here.
Now let’s get started!
Create a form with what ever method you prefer. In the image on the right, I have used a non-hidden field in Contact Form 7 to easily see my results. To hide an html form field, simply use; type=”hidden” or [hidden textarea-someid] id:guid], in contact form 7.Â
Head over to Google Tag Manager and click Variables -> New. Then “User-Defined Variables” -> “Custom JavaScript”.
Then, enter the code below and copy the Variable name you set (highlighted in yellow) as we’ll need it in the next step.
function(){
return ga.getAll()[0].get(‘clientId‘);
}
Setup a New “Custom HTML Tag”. Make sure the last line matches your form field name and the value is where you paste the Variable name we just set up.
<script type=”application/javascript”>
var gclid_field = document.querySelector(“#gclid_field”);
gclid_field.value={{Store GA ID}};
</script>
Now we need to add a Trigger to fire the contact form filler Tag with the Client ID from the previous step. Just to be safe, we’ll add the Trigger as Page View – Window Loaded, which waits until the entire page is rendered before firing. This should avoid any conflicts.
Load the script only on the pages you will be capturing on. Add as many URLs’ as needed.
Next, I’ll add the Trigger to the Tag that inserts the Client ID into the form, called “GA ID Filler” on my setup.
Of course, you can submit your Forms to any source such as; email, Zapier, or another CRM altogether – but I’m using HubSpot today.
Assuming your using HubSpot’s tracking code which detects third-party form submissions, simply setup a contact field to hold our new GCLID.
Navigate to your HubSpot Settings, Click Data Management -> Properties -> Create property. I’ve put mine under the “Conversion information” category.
If you create the internal name to match your forms ID (above we used “gclid_field”) then HubSpot will automatically detect the corresponding field upon submission. If anything, use the field matching process on the Marketing -> Forms Page.
You can learn more about adding custom fields to HubSpot here.