When a lead converts offline: reporting post-conversions with Google measurement protocol

2022

How to report conversions into Google Analytics and Google Ads with near 100% accuracy?

In a lot of cases the standard conversion measurement (using pixels) doesn’t work accurately - browsers implement new policies that distort the measurement or a sale happens later on and needs to be reported manually.

CRM has to receive a user data, and be able to report a sale later on back to Google Analytics and Google Ads/Meta Ads (also called offline conversions or post-conversions). We are aiming to achieve the following result:

  • Conversion is stored in the google spreadsheet and is editable
  • Post-conversion is reported from the google spreadsheet to the GA and then automatically transferred to Google Ads account
  • Post-conversion includes Value
  • Post-conversion is attributed up to a Search term level in Google Ads
  • Post-conversion reporting works across channels (organic, direct, affiliates, etc)

To solve this problem we can use Google's proprietary Measurement protocol - an underlying standard behind Google Analytics data reporting. To put things in a simple way, we can upload conversions manually into Google Analytics using a simple url link.

To do that we have to create a new custom event in Analytics and have a few user parameters gathered along with a lead’s form submission. Parameters are:

  • Client ID - a unique number assigned by Google Analytics for every session/user;
  • GCLID - Google Click ID, applied to the url each time the user clicks on the ad.

Combination of above mentioned parameters allows to report the lead manually into Google Analytics servers using a hit on the preconfigured link. Example for the Universal Analytics:

https://www.google-analytics.com/collect?v=1&tid=UA-XXX-1&t=event&ec=Lead&ea=Closed&el=Won&ev=1000&gclid=CjwKmCAiAv7rf2OMBhAQ&cid=899697415.1641066219

Opening this link (sending a hit) would send a conversion with a value of 1000 to google analytics server. Within a day conversion will be added in the reports and sent to the Google Ads account and attributed up to search term level.

If you are using GA4, then here's a link to a google's event builder where you can send a hit manually

To conclude, in order for the setup to work we need to gather 2 ID’s for each new user:

  • Client ID (example - 123456789.987654321) - this ID is assigned by GA
  • GCLID (example - EAIaIQobChMIn8GPrK_03) - this ID is assigned by Google Ads

When a user hits the “submit” button, the form should be sent along with the Client ID & GCLID, so we can identify a user in the Spreadsheet microCRM. Our data sample would look like this:

John, [email protected], 123456789.987654321, EAIaIQobChMIn8GPrK_03

Setting up landing page for post-conversions

Now we need to fetch Client ID from the counter and send it along with the form in a hidden string.

GA4 setup through the GTM:

1. Create a new GTM container, add GA4 configuration tag

GTM tags

2. Add a GTAG GET API tag through template gallery (I called this tag cid). This is as per Simo Ahava's blog post.

Gtag Get

3. Add a custom HTML tag that will post a value into the hidden field when user sends a form

Client ID to html form

4. Add a Delayed Pageview to make sure that all the code is functional after the page is loaded (here's a blog post with more explanation)

Delayed pageview

5. Add a variable in the variables tab:

Client ID variable in GTM

6.Variable name is gtagApiResult.client_id

Client ID variable in GTM

Google Universal Analytics setup (will be deprecated in 2023):

    <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-XXXXXXXX-1', 'auto'); 
        ga('send', 'pageview'); 
       ga(function(tracker) { var clientId = tracker.get('clientId'); }); 
    </script> 

This enables us to fetch Client ID parameters for a Universal Google Analytics.

Add this script to GTM or your .js file

        document.addEventListener('DOMContentLoaded', function(){
          $(document).ready( function() {
              ga(function(tracker) {
                var clientId = tracker.get('clientId');
                $("#cid").val("'" + clientId);
              });
            });
        });

Update your .js file

Add the following code snippets into your .js file:


// Parses Gclid from the URL

        function getQueryVariable(variable) {  
        var query = window.location.search.substring(1);                   
        var vars = query.split("?"); 
            for (var i=0;i var pair = vars[i].split("="); 
                if(pair[0] == variable) { 
                return pair[1]; 
                } 
            } 
        return(false); 
        } 
        window.onload = function getGclid() { 
            var value = getQueryVariable("gclid"); 
            var e = document.getElementById("gclid"); 
            e.value = value;
        }


Setting up Google Analytics & Google Ads for post-conversions

In order for the setup to work, we need to create an event in Google Analytics and link it in the Google Ads. Below example is for GA Universal.

In GA4 create a custom event "post_conversion" and mark it as conversion (be aware that events populate in GA4 reports with a significant delay)

creating a custom event in GA4

In GA Universal create a Custom event "post_conversion". Make sure to fill in Category, Action & Label.

creating a custom event in GA Universal

Now open Google Ads Conversions tab and Link your GA and then import post_conversion with enabled Values:

importing conversions from GA to Google Ads

High-Converting Landing Page Template for PPC

Manage Your Leads With Ease With a Google Spreadsheet. Accurately report Leads Using Measurement Protocol. Improve Your Google Quality and Lighthouse Scores.

Download

Get the template for free (beta)