Manual or offline conversion tracking with Google Ads

Python and Google Ads logo side by side

One of the biggest challenges today with promoting your website is paying attention to what services you install on it and the data these services collect about your users. Especially in light of EU rulings that throw doubt on the legal frameworks we use to transfer data to US-based services. We were wondering if it was still possible to run effective campaigns without using Google Analytics and Google Tag Manager.

To make our GDPR compliance easier, we opted for an alternative to Google Analytics (Plausible.io) which is EU-based and says that it does not use cookies or collect any personal data for the analytics it collects

plausible.io's public analytics dashboard

Plausible provides their own home page’s analytics as a public dashboard for anyone to view.

While we were able to get some great insights into the usage of our site and the source of the traffic, a lot of services require you to install a tracking script on your page to detect click or navigation events. One common usage is for detecting a conversion event on a marketing campaign. This is used to increase the effectiveness of said campaign by optimizing who is targeted by the campaign dynamically and also re-targeting a given user after a certain amount of time. This increases the effectiveness of your campaigns and should increase ROAS.

infographic showing a summary of how Google Ads conversion works

If we take Google Analytics as an example, the issue with this is that the amount of data collected through the script running on your site can be quite extensive. We decided to see if we could reduce this to the absolute minimum by only telling the marketing platform (in this case Google Ads) which user id (“gclid”) converted, and nothing else. This id is something that is generated by Google and the user interacting with Google search. 

infographic of a custom conversion flow where data passes through our own server

A few challenges

What we need to solve:

  • Any request on the internet reveals your IP address and other details about the device you are using. We should find a way to avoid our users revealing their personal data.

  • Google Ads does not provide an “off the shelf” or copy/paste way to manually trigger conversions. We need to find a way to use their APIs to trigger a conversion manually.


Some solutions

Let’s find a way to capture the “gclid” (which is the unique identifier for a user clicking on a Google Ad) and send it back to Google from a secure place which does not reveal anything else about the user.  

Investigating the Google Ads API

Google provides a client library with some sample code and examples on manually uploading conversions through their API. This should help us get started. 

The client library seems pretty straightforward to use except for the fact that you need to apply for a developer token, a process which can take up to 3 days if you want to use it in production. We also need to set up a Service Account to access the API on our behalf.

Looking for a hosting solution

OVHcloud sign on building

Since this will trigger every time we have a conversion, it should be ready to run from the cloud somewhere. And since we are looking at EU-based services, let’s go with OVH for hosting our function. This will mean that Google Ads API will only see requests coming from our server in France and not the end user’s personal data (except for their “gclid” of course).

Making our own tracking script

The final piece of the puzzle is our own script which should trigger from a conversion and send the data to our server. This is standard javascript and is pretty straightforward to implement. When users come from a Google Ad with auto-tagging enabled, the “gclid” is added to the end of the website url by Google automatically (for ex: https://techi.be?gclid=123xyz), it’s important that we store this in the user’s browser storage for later as conversions could happen later during their visit to your site. We need to make sure that we only trigger conversions when people come from a Google Ad.

Implementation

Step 1: Set up Google Ads

In order to begin, a Google Ads account is needed with a campaign and custom conversion action

Step 2: Get access to the API

We followed the Google API guide on creating a service account and developer token. This was quite a complex process involving multiple accounts, documentation sites and submitting a formal request to Google explaining our use case for the developer token.

Step 3: Write a conversion upload function

We wrote some Python code to manually send a conversion event to Google Ads. It’s based on a code sample provided by Google

Step 4: Create a small server

Our function needs to be triggered when our users convert. This is typically done by making a request to a server which can then trigger our function.

We installed Flask in our project. It is a very simple Python server that should be enough to get the job done.

Since the Google Ads API credentials we are using are secret, we don’t want to reveal them on the website.

Step 5: Host the server

A little VPS in OVH Cloud was then set up to be accessible to users on our website. Everything was straightforward here, no hiccups. 

Step 6: Add a custom script to our website

Finally, we were able to start writing our custom tracking script. We attached a function to the onclick event of the element we wanted to track the click from, checked the referrer, checked for a “gclid” and then sent the data to our server.

Step 7: Wait for results

Now we can let it run and wait for our Google Ads Campaign to start reporting conversion statistics.

Final thoughts

nasa photo of earth at night from space

While it’s easy to find alternatives to US-based services for a website, it’s very difficult to make full use of marketing platforms without revealing customer personal data in the process. This forces you to decide between the privacy of your customers and the cost to acquire them.

In the end, we did find a way to trigger a specific conversion event on Google Ads for a user who converts on our website. The solution we came up with feels like a good balance between respecting privacy and still being able to run effective campaigns.

Data is collected from the user by them using Google search and getting attributed a “gclid”. All we do is tell Google that a “gclid” has been converted. Google Ads can then optimize based on data that they have collected. 

This is actually more useful if your conversions happen in another system or offline at a later point in time (max. 90 days according to Google). You could collect the “gclid” and upload them from a csv file at a later point in time.

For standard website setups, I’m not sure that it was worth it given the amount of digital gymnastics it took to set everything up. Adding new conversion events is also not very user friendly compared to using Google Tag Manager. This means that it will be more costly to setup and maintain.

Will our users really care about this? Will our customers be willing to pay the extra cost of adding a privacy layer? Personally, I appreciate a setup where people are not forced between accepting to be tracked or digging through cookie pop ups to reject invasive tracking. Hopefully we see more off the shelf solutions in the future where anyone can just set this up with a few clicks.

How we can help

All the links that we followed for the various steps in the setup are included in the article if you would like to try something similar. 

If you are not sure where to start or how to do this yourself, we would be happy to help. We also do standard setups.

Get in touch so that we can set up a meeting.

Previous
Previous

Creating an email version of ChatGPT using OpenAI

Next
Next

Adding a React component to your Squarespace website