Profit Over Ad Spend based tracking for Google Ads and Google Analytics

Apr 24, 2024
Apr 15, 2024

More and more businesses are now focused on precise and effective tracking in their digital marketing strategies. The ability to accurately assess the performance of campaigns is crucial for maximizing return on ad spend (ROAS). But another important metric is Profit Over Ad Spend, which offers a more holistic view of a campaign's effectiveness.

While ROAS focuses primarily on the revenue generated per dollar spent on advertising, it doesn't account for the cost of goods sold or other expenses related to the product or service being advertised. This is where Profit Over Ad Spend steps in, providing a more comprehensive perspective. 

Profit Over Ad Spend takes into account the actual profit generated after subtracting these additional costs. By considering not just the revenue, but the profit, Profit Over Ad Spend offers a deeper insight into the true financial return of advertising campaigns.

In practice, this means that a campaign with a high ROAS might not necessarily be as profitable as it appears if the associated costs are high. Many businesses want to hide the real numbers from the competitors, or they just want to keep this sensitive data away from others.

So in this blog post we will describe how to set up Profit Over Ad Spend based tracking for Google Ads and Google Analytics and how to use server Google Tag Manager with Firestore, to pull in sensitive profit data (or other sensitive data) and report it to the Google Ads products in place of revenue as the conversion value. This enables profit bidding, with real time conversion uploads, in a way that protects the sensitive profit data from a determined user.

How to set up Profit Over Ad Spend based tracking: 1st methodCopy link to this section

What is needed for a successful setup:Copy link to this section

  1. Google Cloud project with Firestore in Native mode.
  2. Accessing individual product profit information before a transaction occurs.
  3. Google Analytics or Google Ads accounts. 

A quick overview:Copy link to this section

  1. Begin by setting up your tags on the site using a GTM web container. Configure this container specifically for a purchase event.
  2. Next, ensure your website is prepared to handle an e-commerce purchase event in its data layer, which should include the revenue data. When a purchase occurs, this event will trigger, effectively sending the data payload to server GTM.
  3. Then, attach a custom variable to a tag that is activated by purchase events. This variable should be designed to pull profit data from Firestore, replacing the original revenue conversion value with this profit figure.
  4. Finally, send this modified event, now featuring the profit conversion value, directly to Google Analytics or Google Ads. This step ensures that the tracking data you are collecting focuses on profit, providing a more accurate and valuable insight into your advertising performance.

Setup:Copy link to this section

1. Set up your GA4 configuration to actively send events to the server container.

Set up GA4 configuration - stape

2. Set each Firestore document ID to the product ID, this way it's easy to fetch the right document by a single lookup. 

Create a product collection. For each product, add a corresponding document to this collection. Ensure that each document includes a field specifying the profit value.

When configuring the variable in server GTM, specify the Firestore collection name and the document field.

3. Download gPS Soteria on GitHub -> Open templates sections in the server Google Tag Manager container -> Click New.

4. Click three dots in the top right corner -> Click Import -> Select the template you’ve recently downloaded from GitHub -> Click save.

gPS Soteria on GitHub - stape

Go to the permission tab and set the permissions for Firestore, ensuring you update the project ID.

persmissions in server gtm - stape

5. In the HTML data layer, there’s a revenue value. This value is then exchanged for the profit value within the server-side container. The profit value is retrieved from Firestore using a custom profit variable template that you just set up:

  • When the purchase event triggers, it activates the GA4 tag as well as the Google Ads Conversion tag.
  • A custom profit variable is linked to this tag, designed to substitute the original conversion value.
  • This profit variable operates using a specific custom variable template to extract profit data from Firestore, aggregating the total profit of all items purchased.
  • And the event, now bearing the revised conversion value, is communicated to Google Analytics and Google Ads.

6. Attach a Google Cloud service account to the deployment.

We have a detailed article on how to connect Google Service Account to stape. Don’t forget to grant access for the Firestore Project.

7.  Go to variables -> new user defined variable and create a “profit” variable from the profit variable template.

8. Go to tags and click on new.

1. Set up for Google Analytics 4Copy link to this section

Select an GA4 tag. In the “Parameters to add / edit” replace value with the profit variable. 

ga4 tag - stape

2. Set up for Google AdsCopy link to this section

Select a Google Ads Conversion Tracking tag. In the configuration add the profit variable to the 'Conversion Value' field. 

google ads tag - stape

9. The trigger should be a custom event for purchase events.

10. Save and deploy the code.

How to set up Profit Over Ad Spend based tracking: 2nd methodCopy link to this section

gPS Phoebe allows obtaining real-time predictions from a Vertex AI model. These predicted values can then be employed as confidential conversion values for value-based bidding strategies.

What is needed for a successful setup:Copy link to this section

  1. A Vertex AI endpoint with the model you want to use.
  2. Google Cloud project with billing enabled
  3. Google Analytics or Google Ads accounts. 

Setup:Copy link to this section

1. Download gPS Phoebe on GitHub -> Open templates sections in the server Google Tag Manager container -> Click New.

2. Click three dots in the top right corner -> Click Import -> Select the template you’ve recently downloaded from GitHub -> Click save.

gps phoebe - stape

3. Now in the Variables section click on New and add Vertex AI Prediction.

gps phoebe - stape

Complete the configuration by filling in the details of your environment. In addition to the mandatory fields, it's necessary to include the request data that is to be dispatched to the Vertex AI endpoint. The nature of this data is contingent on the specific requirements of your AI Model.

4. Navigate to the appropriate Tag associated with the purchase or conversion event. Here, replace the conversion value (or a similar field) with the variable you have newly created, which contains the predicted value from Vertex AI.For example:

Use caseCopy link to this section

You add to the Data Layer a real Profit and Margin, but these numbers are hidden by some secret formula that only knows your backend and you.

profitinDL = 4861

real profit = (4861-100)/69

Basically you send 4861 from web to server GTM. Then, in your server container, you can add a custom variable that does: (4861-100)/69 - and add this field using transformation.

Please notice that the backend always knows the correct profit, so it can write the correct profit to Data Layer. You need to have only one formula for hiding real profit.

This formula is used only for hiding data and not for actual profit calculation from price.

So, this formula is always static. You can use it for all numbers you want to secretly pass to the sGTM from Data Layer.


real profit = 69

on backend = 69*90+100 = 6310, and put in Data Layer 6310

on sGTM = (6310-100)/90 = 69 which is real profit that we send to gAds.

ConclusionCopy link to this section

Profit Over Ad Spend provides a more realistic view of the financial impact of advertising campaigns, accounting for underlying costs. We hope that with this article you will manage to keep sensitive data protected while still benefiting from Google's advanced ad targeting and optimization capabilities. With real-time conversion uploads and profit bidding, you are now empowered to maximize return on investment, fine-tune your marketing strategies, and gain a competitive edge.

Remember, successful implementation requires a careful setup. Once in place, this Profit Over Ad Spend-based tracking system offers a more transparent, effective, and secure way of measuring and enhancing the profitability of online advertising efforts.

Need help with the setup?

Don't worry, we've got you covered! Click on Get help and we will send you a free quote.

Get help

Host your GTM server at Stape