> For the complete documentation index, see [llms.txt](https://docs.adpage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.adpage.io/integrations-websites/custom/add-backend-webhooks.md).

# Add backend webhooks

Learn how to setup custom webhooks

### Before you start

This article picks up where [Custom User Data](/integrations-websites/custom/add-user-data-script.md) and [custom datalayer](/integrations-websites/custom/add-datalayer-events.md) leaves off. Make sure all of the steps in the [Setup AdPage container](/getting-started/setup-adpage-container.md) article have been followed. Which means that:

* [ ] Your **AdPage container** is created.
* [ ] Your AdPage container is **connected to your GTM server container**.
* [ ] The **CNAME record** is added in your DNS settings, so tagging runs on your own (sub)domain.
* [ ] The custom [user Date scripts ](https://docs.adpage.io/integrations-websites/custom/add-the-custom-user-data-script-to-your-website) setup are correctly on your site.
* [ ] The [eCommerce dataLayer](https://docs.adpage.io/integrations-websites/custom/custom-ecommerce-datalayer-and-backend-webhooks-setup) is correctly on your site.

### Install webhooks

Backend [webhooks](https://www.adpage.io/post/webhooks) provide more accurate measurement. In eCommerce, send a webhook when an order is created. This is the primary conversion.

Webhooks require additional website configuration. Test the implementation thoroughly.

Send webhooks to configures server container URL for example:\
`https://tagging.domain-name.com/order_created`&#x20;

### The webhook payload

Use the following payload for an eCommerce website. Send it in JSON format. Do not deviate from this example. Changes can negatively affect tracking.

```perl
{

  "event": "trytagging_purchase",

  "ecommerce": {

    "transaction_id": "43",

    "affiliation": "",

    "value": 45.0,

    "tax": 0.0,

    "shipping": 0.0,

    "currency": "EUR",

    "coupon": "",

    "items": [

      {

        "item_name": "copy hoodiiiee",

        "item_id": "23",

        "price": 45.0,

        "quantity": 1,

        "index": 1

      }

    ]

  },

  "user_data": {

    "customer_id": 1,

    "customer_email": "jeroen@adpage.io",

    "customer_name": "Jeroen Test",

    "customer_phone": "0612345678",

    "customer_address": "Velmolenweg 54a",

    "customer_zip": "5404 LD",

    "customer_country": "NL",

    "customer_city": "Uden",

    "customer_state": "Province",

    "customer_country": "Netherlands",

    "billing_first_name": "Jeroen",

    "billing_last_name": "Test",

    "billing_address": "Velmolenweg 54a",

    "billing_postcode": "5404 LD",

    "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": "",

    "new_customer": "true"

  },

  "marketing": {

    // Front-end marketing data and the following field:

    "ip": "visitor_ip_address"

  }

}
```

### The marketing object

The marketing object comes from the front-end tracking script. Send this data object in the backend webhook payload. See [add custom user data script to site](/integrations-websites/custom/add-user-data-script.md).

{% hint style="info" %}
The following function is only an example. Do not copy it directly.
{% endhint %}

```javascript
var marketingData = window.taggingHelpers.getMarketingObject();
var jsonString = JSON.stringify(marketingData);
var base64Data = base64Encode(jsonString);
   
setCookie('trytagging_user_data', base64Data, 30);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.adpage.io/integrations-websites/custom/add-backend-webhooks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
