Skip to Content
Offline Events

Tracking Offline Events in Server-Side

Offline events refer to user interactions that occur outside of a website (or a mobile application).

These events can include:

  • In-store purchases
  • Conversions via phone calls
  • Lead form submissions through a CRM
  • Or any other offline action you want to track and attribute to your marketing efforts.

Tracking these additional events is relevant for:

  • Unified customer journey analysis (online+offline)
  • Attribution of offline conversions to your media campaigns.

With Google’s Measurement Protocol API and your GTM Server, you can send these offline events to platforms such as Google Analytics 4, Google Ads, Meta, or other third-party services.

Sending Offline Events to Your Providers via Your Server

To track your offline events, we recommend using Google’s Measurement Protocol API, which will make the process significantly easier.

Here are the key steps to send an offline event to your media and analytics providers:

How to send offline events to your server
  1. Collect an offline event (e.g., an in-store purchase) in your internal tool.
  2. Send the event data to your GTM server using the Measurement Protocol API.
  3. On your GTM Server, the Measurement Protocol client receives this request.
  4. The event data is processed by the client and made available in the event data table.
  5. You can then configure your tags from your GTM Server to send this offline event and its key information to your media and analytics providers.

Now, let’s go into detail on the steps to send your offline events to your Server.

Step 1: Create a New Measurement Protocol GA4 Client

  1. In your GTM Server container, click on the “Clients” tab and then on “New”.
Creating a new client in GTM Server
  1. Then select the “Measurement Protocol (GA4)” client.
Creating the Measurement Protocol client for offline events
  1. Name this client “Measurement Protocol”, and enter the path /mp/collect in “Activation Path”.
Creating the Measurement Protocol client for offline events
  1. You must then publish your GTM container by clicking on Submit
Publishing the GTM Server version so the Measurement Protocol is functional

The new Measurement Protocol client is now ready to receive the offline requests that you will send to your tracking server!

Step 2: Send Your Offline Events to Your GTM Server via Measurement Protocol

You can collect offline event data from sources such as:

  • CRM systems (e.g., HubSpot, Salesforce, etc.)
  • Point of Sale (POS) systems
  • Call tracking tools
  • Lead generation forms

The collected data can include:

  • User identifiers (e.g., email, phone number, user ID, hashed data)
  • Event details (e.g., transaction ID, revenue, products, timestamp)
  • Marketing attribution data, depending on the provider you are sending events to, such as:
    • Google Ads offline: sending the Google Click ID (GCLID)
    • Facebook Ads offline: sending the Facebook Click ID (FBCLID)
    • UTM parameters: for sending offline events to other media providers.

To send requests to the GTM server in server-side mode, a standard API call must be made using the following information:

URL : https://metrics.example.com/mp/collect?measurement_id=G-XXXXX Method : POST Headers : Content-Type: application/json Body : See detailed example below
⚠️

Warning: Make sure to replace metrics.example.com in the URL with your own tracking subdomain, and G-XXXXX with your GA4 property measurement ID.

Body: Here, we take the example of an in-store purchase, with the sending of a request for an offline purchase event.

For other types of events, you can find all the information about their optimal structure in Google’s documentation.

{ "events": [ { "name": "purchase", "params": { "currency": "EUR", "transaction_id": "1234", "value": 50, "items": [ { "item_id": "1", "item_name": "test", "price": 40, "quantity": 1 } ], "user_id": "test_user_id", "user_data": { "email_address": "[email protected]", "sha256_email_address": "hashed_value", "phone_number": "0600000000" } } } ] }

Now, let’s validate that this request is working properly by testing:

  1. That the request is functional by using a tool to simulate sending an offline event.
  2. That the event is correctly received server-side via GTM Server preview mode.

Step 3: Testing Offline Event Requests to Your Server

To test the configured request from the previous step, we will simulate sending an offline event using the free tool Postman.

  1. Open Postman and click the “+” button to open a new tab.
Using Postman to send a test offline request to your GTM Server
  1. Choose the POST method and enter the URL, as in the example https://metrics.example.com/mp/collect
⚠️

Make sure to replace “metrics.example.com” with your own tracking subdomain!

In the Body tab, select the “raw” option and the JSON format.
Copy the test request of the online event you want to test.
In our example, we copied the request for the purchase event created in step 2.

Send a test offline event request to your server
  1. Open your GTM Server container and click on “Preview”
Preview an offline event on your GTM Server
  1. Click on the three dots (top right) and select “Send requests manually”
Manually send requests to your GTM Server for offline events
  1. Copy the token that appears for the preview HTTP Header
Preview HTTP Header for GTM server
  1. Go back to Postman, and in the Headers tab, fill in:
  • The key: X-Gtm-Server-Preview
  • The value: the token previously retrieved from GTM
Use Postman to manually send offline event requests to GTM Server
  1. Click on “Send”.
    If the request is correct and successfully sent, you should see a response with status 200.
Offline event test request successfully sent from Postman

Step 4: Preview your offline test events in GTM Server

Now that we’ve tested sending the test requests, let’s see how to view the offline test events sent to your GTM Server to verify:

  • that the Measurement Protocol client properly claims these incoming event requests on the server.
  • that the data sent for your offline events is properly available in the “Event Data” tab.

In the GTM Server preview, you should now be able to visualize the offline events you’re sending to your server.
We sent a test for an offline purchase event in the previous step via Postman, and we can now view it in the preview.

  1. The event appears on the left side of the screen, and the Measurement Protocol client has correctly claimed this incoming request.
Offline event request received on the GTM Server and claimed by the Measurement Protocol client
  1. From the Event Data tab, we can also verify that all the parameters sent in our test request are present (user-data, items, transaction_id, value, etc.).
Preview in GTM Server of an offline event request and event data

We can later use this data to send these offline events to platforms like Google or Meta!

Bonus: Preview Your Real Offline Events in Production

Earlier we saw how to preview a test event sent from the Postman tool. If, however, you want to preview your actual offline events being sent in production, there’s one final setup step.

  1. From your Addingwell container, click the Tagging Server tab, then click the pencil icon in the Info card > Preview Header Token
Test sending your offline events to your GTM server via Addingwell
  1. Then paste the preview HTTP Header token you previously retrieved from GTM into Preview Token (see Step 3.5).
    Also limit the token to the specific path /mp/collect in the “By path” tab to filter offline data. You can also add a specific IP address in the “By IP” tab to filter the data and receive only your test events.
Test sending your offline events via Addingwell and narrow down your tests

The token is deployed within a few minutes and is automatically deleted after two hours. You will need to repeat this process on Addingwell the next time you want to visualize your offline events in production.

You can now visualize your offline events in production in the GTM Server Preview.

Congratulations 🎉

Well done, you’ve successfully configured the sending and receiving of offline events in a server-side setup! 🚀 If you have any questions or encounter any issues, feel free to reach out to our support team, who are ready to assist you every step of the way.