If your site uses Google Analytics then you can connect your account to Driftrock to capture UTM source, medium, campaign, content and keyword for all the events that you send to us.  These events might be leads from your website forms, or other avenues, like one of our CRM integrations.

To make this work, three things are required:

  • You must connect your Google Analytics account via the Integrations console.
  • Events (e.g leads) must contain a Google Analytics Client ID, mapped correctly in field settings.

How to extract and send the Google Analytics Client ID

For website forms, we provide a simple script for capturing the Google Analytics Client ID and setting it in your form.  Here's a step-by-step guide on using the Driftrock script:

1. Make sure you have the latest version of Google Analytics code on your website. 

2. Add the following script at the end of the <body> section of the web page(s) where your forms live (or across all your web pages if it's easier). 

<script type="text/javascript" src="https://assets.driftrock.com/js/drga.js" ></script>

3. Add a hidden field to your form with the name ga_client_id or an appropriate name, which you'll reference in step 4. 

For example: 

  <input type="hidden" name="ga_client_id"></input>



Make sure your CRM system is configured to accept the new hidden field with the name you specify (in this example ga_client_id ). 

If you are sending all your lead data to Driftrock for your lead management, then Driftrock already has the field ga_client_id ready by default.

4. Call the dRock function from the Driftrock script you added in step 2. 

Calling this function will add the Google Analytics Client ID from the Google Analytics cookie and insert it into the hidden form field we created in step 3.

The dRock  function will let you specify the name of the field. 

For example:


In this example, the ga_client_id  in this example is the name of the hidden form field we added in step 3. 

You can optionally specify a callback function to execute after the dRock  function finishes. For example, you may want to set the Google Analytics Client ID, then trigger your form validations. e.g:

dRock('ga_client_id', nameOfValidationFunction);

Here is an example of how the finished page code might look:



      <input type="hidden" name="ga_client_id"></input>



    <script type="text/javascript" src="https://assets.diftrock.com/js/drga.js" ></script>

5. Test the tracking is working correctly by submitting a lead on your page

Give the tracking a try by submitting a lead on your form, and checking the lead in your CRM system (or Driftrock) to see if the test lead contains a ga_client_id  field with a value like this 1976480996.1560959366.

Feel free to contact our support team if you need help.

Did this answer your question?