Using Google Tag Manager to Score Leads for Google Analytics & Google Ads

Published on December 12, 2020 by Chris Green

I have seen too many campaigns where the number of leads and cost per acquisition is reported on, but whether or not the leads themselves are worthwhile or lead to a positive ROI is unknown.

In this blog, we’ll run through a method of bringing more insight into this process, where the leads>sales part of the cycle is disconnected or obscured, you can grant yourself a better view of what is going on.

Assuming you are running Google Tag Manager (alongside Google Analytics & Google Ads) hopefully the ideas/method discussed here will add some food-for-thought!

Gaining a Better Understanding of Lead Quality

Proving your ability to generate the right leads is a key part of any marketing strategy – ultimately that’s what delivers a return on investment! In businesses where the sale takes place offline the time from a contact form (or lead – depending on the process) to a sale can vary widely.

This lag creates a sense of ambiguity around the cost of the sale the appropriateness of the opportunity and the channel it came from. Not many companies map this end-to-end, as well as they, could do, let-alone provides this data to those managing the marketing campaigns for them.

The best way is ultimately merging customer/sales data and connecting it directly to the marketing process, but where this cannot be done, lead scoring at the source (GA/GTM) offers a “next-best” way of understanding what value is being created and even offering the potential of optimising to this in ‘real-time’ rather than in hindsight.

The Form Field Capture & Calculation Method Using GTM

Let’s start with a form & the fields we want to track. In this example, there are two fields in the form which give us information around the person submitting the form which better qualifies the sale – Income & Number of years at their current address.

We need to identify the IDs of those fields – this will be what we can use to select the value using Google Tag Manager. It is possible to select the field by the Class too, but the ID is the most straightforward in my opinion.

Next, we write some basic JavaScript to capture that information from the form. For this, you’ll need to create a Custom JavaScript Variable. Don’t worry if you’re not well-versed in JavaScript, the example is below.

When writing the code, this is where the ID from the form field comes in handy. You can see the example we’re working with here – replace ‘income’  with the name of your ID you’ve selected and then change ‘variableName’ (two mentions) to whatever you want to call this – make it something unique and descriptive.

function () {
var variableName = document.getElementById("income").value;
return variableName;

There are some more complex things you can do with this, but for now, we’re just assuming we want to extract the value that is selected. This will then be passed onto a Lookup variable within GTM later on – not the most sophisticated, but it’s functional.

Once we can capture the field values (I created two here, one for the income and another for the time at the address), we need to establish a method to score them.

For this, we create a lookup table in GTM, select the JavaScript variable (“JS – Income Capture”) as the input. Head back to your contact form and look at the possible inputs. In this example, we have a drop-down box, so we copy & paste in the exact values it contains. If this were a free-text field, for example, we might want to create a Regex Lookup variable instead and then write some regex to match inputs with certain criteria.

NB: it’s worth setting the default value with “0” to prevent any calculation-breaking issues later on if the form fields don’t match with the lookup for any reason.

As we have multiple fields we’re looking to score, we need to calculate a total. Again, another simple JavaScript variable can cover us here. If you only have one field you want to score, then you can skip this step!

function () {
var i = parseFloat({{Lookup - Income}});
var t = parseFloat({{Lookup - Time at Address}});
return (i + t);

Here the logic behind the scoring and the final calculation is pretty basic – in the real world, chances are that criteria for a “good” lead and a “bad” lead may be more nuanced. To get the most value out of this process, take some time to understand this.

Do you record previous contact data? Can you run some analysis to see what factors positively (or negatively) influence a lead’s value? Anyone running a CRM system should have this data or may even be running a lead scoring system already – if so, and you trust that logic, start here!

Finally, we need to ensure that this value is being sent with the event which tracks the form submission. We need to ensure the calculation variable is included within the “value” field on the Event tag.

This data can be segmented when it gets sent into Google Analytics. The screenshot below shows a segment for event values over 70 and under 70.

You can configure these segments to include different values and break them down more granularly, initially, you’ll have to go by your best first guess, but you can create new segments laters as needed.

If you can segment the data by something in GA then you can also create an audience too! These audiences can be really powerful in Google Ads – and you can create lookalike audiences to find a previously hidden pool of high-value customers you’d otherwise struggle to find.

With the audiences, if you’re unsure which ones you’ll need – or how many – err on the side of caution here, as audience data only builds when you establish the audience.  Campaigns with a large amount of traffic will not have a problem here, but lighter budgets may struggle.

Finally, if you want to pull this event value into Google Ads (without setting up additional tracking), you can introduce this value into a goal conversion.

Pulling the conversion value in can improve the reporting in GA and can help you understand campaign value better – i.e. which sources send the best leads, what kinds of engagement drive better customers, etc. In addition, this value can be used within Google Ads along-side smart bidding so you can run your campaigns to optimise to conversion value – rather than just the number of conversions. Remember, we’re going for better conversions, not just more conversions!

Form Field Capture & Privacy

An important note here is that this method does not store/capture any values which could lead to PII issues in GA. If you decide to start capturing and storing any form data within Google Analytics, you need to take into account whether or not this complies with privacy laws in your (and your customer’s) region.

Other Tweaks/options:

There are other tweaks or options you can employ here – this is intentionally basic to get the point across – but should you want to take this further, here are some potentials:

  • Score the presence of optional fields (i.e. is a phone number present?) to add value to more complete conversions
  • Detect the use of Gmail/Hotmail/Yahoo email addresses and reduce the score (often a negative factor in B2B sales process)
  • Store values in a cookie/local storage – i.e. if you want to include this score as part of any other site interactions. Just be careful with privacy implications (above)
  • You could even look for certain keywords in free-text fields and then score the form submissions based on that.

If you have any other ideas here I’d love to hear them – my contact details are below!

Using Lead-Scoring as Part of a Day-to-Day Campaign

I speak to many different markets who have a differing view on Google’s Smart Bidding solutions, some love them, some won’t touch them, and others haven’t made the leap of fair yet. Whichever of those camps you fall into, using this method to optimise campaigns should be approached in a structured and testing mindset.

What I wouldn’t advocate is switching to this method of conversion optimisation all at once. You need to validate that these leads are more valuable in the real world (i.e. that offline conversion is still strong) and you need to understand what this optimisation does to cost per acquisition and then ROI.

If CPA when up as a result of this, it would be too easy to dismiss the method as failing, but if the conversion to sale rate (or the average order value) rose, then that would have a big impact on overall ROI.

Some may be unwilling to go near the smart-bidding altogether; even if that’s the case, using the audiences of the more ‘valuable’ conversions presents a great opportunity to structure your campaigns differently. Creating lookalike audiences from these campaigns, for example, adds another quality dimension to your campaign-targeting.

At a bare minimum, you can use this data in your attribution reports to understand the value generated by all your (trackable) marketing/media.

So What’s Stopping You?

If you have any questions about setting up this kind of tracking – my DMs are open – or if you have a project that is in motion and you need some more immediate support, you can contact us here.