Measure 100% of your eCommerce conversions through Webhooks

Tobias Pennings
August 19, 2024

Introduction

Measuring conversions is crucial for leadgen Websites and eCommerce Web shops to analyze the success of marketing campaigns. Traditional tracking methods have been impractical for a while now, and even a standard Server-Side Tagging tracking setup cannot guarantee 1-to-1 conversion measurements. These missed opportunities and inefficiencies in your tracking can be solved using webhooks. By using webhooks at the time of a conversion, you can send real-time data directly to your server from your website's backend, enabling 1-to-1 measurements in your marketing and analytics platforms. In this article, we explain what webhooks are, how to use them for accurate online tracking, and the pros and cons of this approach.

What are webhooks?

Webhooks are HTTP callbacks that enable real-time communication between different Web applications. To put it in simple terms, this means that webhooks allow systems to automatically send messages to other systems when certain events occur. Sending those messages goes directly from system to system, allowing information to be exchanged instantly and efficiently.

In the case of online tracking, webhooks are mainly used to detect important events such as user purchases and refunds on the backend of a web shop and send them to an external tracking or analytics tool via your server. When a specific event occurs on the backend of your shop an HTTP request is generated with all relevant data and sent to the preconfigured URL of your server container. In the case of a web shop, you can set it up so that when an order is created in the backend, a webhook filled with eCommerce, user and marketing information is immediately sent to your server. From your GTM server container, you can transform that incoming data in that webhook into the appropriate events and parameters that your marketing and analytics platforms can receive and process.

To best feed a marketing algorithm with data about converting site visitors and to achieve the most accurate overview of conversions by campaign or marketing platform, you want to collect this data as accurately as possible, only webhooks can also cloud your collected data. When does it make sense to use webhooks for your online tracking setup?

When do you use webhooks?

Webhooks for measuring conversions are essential when your tracking setup has a high margin of error in the number of conversions recorded. To fully optimize your marketing algorithms and gain the most comprehensive insights from your reports, webhooks provide that extra step towards complete accuracy and data-driven decision-making. The example below demonstrates how webhooks work in conjunction with a Server-Side Tagging tracking setup.

A common misunderstanding about Server-Side Tagging is the assumption that it provides a 100% accurate method of tracking. While it is certainly more accurate than tracking solutions such as Third-Party Script or Client-Side Tagging, there always remains a small margin for missed visitors or events. Server-Side Tagging provides a solid foundation for accurate tracking, but it is important to understand that it is only one part of a broader strategy to measure as accurately as possible.

Although Server-Side Tagging provides a reliable basis for accurate tracking, there is still a certain margin of error in conversion measurements. This is because creating and sending events to the server is done through Google Tag Manager's web container, which runs within the user's browser. And you yourself have no control over what happens in that browser of your visitors.

There are several reasons why this margin of error may occur.

  • Redirects: Sometimes a user ends up on a page other than the thank you page, where, for example, the data layer is not active. Redirecting site visitors is not stable enough that this can never go wrong.
  • Script loading: Scripts, such as the datalayer script or the tagging pixel, may not load correctly on the thank you page. Websites are usually a hodgepodge of content coming from different providers: ads, analytics, tracking, widgets, social media, etc. Depending on the website design, each of these providers can affect each other's performance.
  • Latency: Latency (the delay between when a request is made through a Web application and when a response is received) can play a major role in a Web site's performance. Among other things, this is an important component for your search engine optimization (SEO), but a slow-loading website can also mean that visitors drop out before a page and its scripts are fully loaded.
  • Users' default browsers: Another common situation is when a visitor goes from the checkout page, say in Google Chrome, to the payment application and then the thank you page opens by default in their device's default browser, such as Safari or Samsung Internet.

Essentially, client-side tracking is vulnerable to these kinds of small but impactful errors. Webhooks offer a solution here, because (except in case of a technical error) you can always rely on the accuracy of the incoming events, without the risks involved in client-side tracking.

In the visualizations below, you can see how the communication flow works for a Server-Side Tagging setup with and without webhooks.

Server-Side Tagging without webhooks

Server-Side Tagging with Webhooks

Besides the errors that can occur in the browsers of your visitors, you cannot see the conversions in your analytics platform such as Google Analytics of visitors who indicate via the cookie banner that they do not want to be tracked (for analytical purposes). With webhooks you do have the ability to measure that conversion so you have an accurate overview in your analytics platform, only you cannot assign that conversion to a previous session or to a user. This is because you didn't get to measure that user and session, so you can't and shouldn't trace the user of the conversion. However, the eCommerce data is included so you have a good overview of the number of conversions and conversion values.

So to effectively use webhooks to attribute conversions to your users or campaigns, you need to include your visitors' user and marketing info. Otherwise, you still can't attribute conversions to your visitors and from which marketing campaigns they landed on your site. Webhooks can't just be set up, there are certain technical and marketing necessities involved in setting up these webhooks so that your marketing and analytics platforms can process the conversion data received.

What do you need to use webhooks?

To deploy Webhooks effectively, there are both technical and content requirements that must be met. First, it is essential to configure an endpoint capable of receiving and processing Webhook requests. This means having a server that can accept HTTP requests and process the data in the correct order. At least with AdPage's servers, you don't have to configure yourself to accept HTTP requests, but transforming the collected data to send it on to your marketing and analytics platforms does. But there are also requirements for the data you send along with your webhooks and thus will transform in your Google Tag Manager server container.

The content of the JSON payload (the marketing object) sent with the webhook must contain various types of information, such as user data and marketing information. The most important thing about the webhook is that it contains the same marketing object used in the front-end. In the AdPage plugins for WooCommerce, Shopify and Magento, this marketing object is stored with an order so that this marketing object is always available to be sent along. Below you can find an example of a marketing object for webhooks:

{
  "event": "trytagging_purchase",
  "ecommerce": {
    "transaction_id": "43",
    "affiliation": "",
    "value": "45.00",
    "tax": "0.00",
    "shipping": "0.00",
    "currency": "EUR",
    "coupon": "",
    "items": [
      {
        "item_name": "test product",
        "item_brand": "",
        "item_id": "23",
        "item_sku": "",
        "price": "45.00",
        "item_category": "Clothing",
        "quantity": 1,
        "index": 1
      }
    ]
  },
  "user_data": {
    "customer_id": 1,
    "billing_first_name": "Jeroen",
    "billing_last_name": "Test",
    "billing_address": "Velmolenweg 54a",
    "billing_postcode": "5404 LD",
    "billing_country": "NL",
    "billing_state": "",
    "billing_city": "Uden",
    "billing_email": "jeroen@adpage.io",
    "billing_phone": "0612345678",
    "shipping_first_name": "Jeroen",
    "shipping_last_name": "Test",
    "shipping_company": "",
    "shipping_address": "Velmolenweg 54a",
    "shipping_postcode": "5404 LD",
    "shipping_country": "NL",
    "shipping_state": "",
    "shipping_city": "Uden",
    "shipping_phone": "",
    "email": "support@adpage.io",
    "first_name": "Jeroen",
    "last_name": "Test",
    "new_customer": "false"
  },
  "marketing": {
    "_ga": "GA1.1.1818643883.1707129196",
    "_ga_LZN92VD7GK": "GS1.1.1711477035.19.0.1711477041.0.0.462628796",
    "user_id": "6fa957c2-52d9-905a-94fe-dfc53b5cef72",
    "client_id": "4132502f-435b-32c1-eaa4-84b37b95f846",
    "session_id": "1711477035",
    "session_count": 19,
    "fbp": null,
    "fbc": null,
    "gclid": null,
    "gbraid": null,
    "wbraid": null,
    "referrer": "",
    "utm_source": null,
    "utm_medium": null,
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
    "ip": "127.0.0.1"
  }
}

While webhooks are very powerful in providing real-time data and automation, their success is highly dependent on how they are set up within the specific platform. This brings us to the next section, where we take a closer look at configuring webhooks in different eCommerce platforms, and how to ensure they perform optimally within your specific environment.

Setting up webhooks for WooCommerce, Magento and Shopify web shops

Webhooks for purchases, among other things, can be set up in various eCommerce platforms through AdPage's solutions. Each platform has its own unique features and requirements for configuring webhooks, which means that the approach varies slightly depending on the platform your webshop is running on.

WooCommerce

Through AdPage' s Wordpress plugin, functionality for WooCommerce webhooks is automatically loaded, in addition to the DataLayer, tagging pixel and cookie recovery function. These webhooks are sent directly to the same server for which the tagging pixel is set when a WooCommerce purchase is made. Only nothing is done with those webhooks until you apply the following settings in the Google Tag Manager server container: WooCommerce webhooks setup.

Magento

Through AdPage 's Magento module, the functionality for webhooks is automatically loaded, in addition to the DataLayer and tagging pixel. These webhooks are sent directly to the same server that the tagging pixel is set up for when you make a purchase. Only, nothing is done with those webhooks until you apply the following settings in the Google Tag Manager server container: Magento webhooks setup.

Shopify

Within Shopify, Notification settings are already present in your store settings. This makes setting up Shopify webhooks easy. Here you can set a webhook towards a specific URL on various backend events, such as a created order or a cancelled order. So for a new order created in the backend, set it to go to your server's URL with /order_created after it: tagging.domainname.com/order_created.

Webhook settings in Shopify

This does work only if you also use the AdPage DataLayer and tagging pixel. Without these components, the marketing object is not automatically populated with the necessary marketing and user info.

To then process the received webhooks via the Google Tag Manager server container to a purchase or, for example, a refund event, perform the following steps: Shopify Webhooks setup.

Made-to-measure

Not using Shopify, Magento or WooCommerce but want to use webhooks for your conversion metrics? Then you can set this up custom as well. This help desk article explains how to set up the AdPage DataLayer, how to populate the marketing object and how to set up the webhooks: Setting up Custom Webhooks.

Conclusion

Webhooks are a valuable addition for eCommerce Web shops that strive for efficiency and accuracy in their communications and data processing. They offer the ability to respond to events automatically and in real time, which not only saves time but can also increase customer satisfaction. Although implementation requires some technical knowledge, the benefits are often significant. Whether you're using WooCommerce, Magento, or Shopify, setting up webhooks can help you take your shop to the next level. Try it out and find out how webhooks can improve your business.