How to send all GA event data to your URL/Site/CRM

A common issue for data analytics or sales managers is the accurate tracking of website users’ behavior and conversions. And often, they might face a problem that has no solution. Or there are no developers that can do this or the next update of the site planed only for next month, etc.

Of course, if you are familiar with the Google Tag Manager, you can send events to your CRM using Сustom HTML, but this is very insecure because anyone can see the requests data and where are they are going. Also, you can’t use API keys for sending data to secure webhooks. And more than that, it slows down your site’s performance because you add additional requests that the browser must handle.

So what the correct solution?

Use GTM Server Side to securely send event/conversion data from any source (site, mobile, other services) to your CRM or any other URL. 

We have many requests from our clients to send event data on conversion to their in-house CRM. And we started using the standard “HTTP Request Tag” for that purpose. After some time, we understood that in most cases, if all data from the event can be sent in JSON Body to the desired URL, that will be enough. That’s why we created a JSON HTTP request tag.

JSON HTTP Request tag for GTM Server Side

JSON HTTP TAG

It sends a POST request to your URL with a JSON body with all event data that came to the GTM client. We also implement the ability to add your custom request headers and data.

Where I can get it

You can find the tag on GitHub and of course, we submit it to Community Template Gallery and expect that it will be shown on it after Google turn on Template Gallery for GTM Server Side.

How the request body will look like

For example, “pageview” event data that comes to the destination URL will look like this:

{
  "x_ga_protocol_version": "1",
  "x_ga_system_properties_v": "j86",
  "x_ga_system_properties_u": "YEBAAEABAAAAAC~",
  "x_ga_system_properties_gid": "958953488.1603993537",
  "x_ga_system_properties_r": "1",
  "x_ga_page_id": 618701935,
  "x_ga_request_count": 1,
  "page_location": "https://gtm-server.com/",
  "language": "ru-ru",
  "page_encoding": "UTF-8",
  "page_title": "GTM Server Side - GTM Server",
  "x_ga_mp1_sd": "24-bit",
  "screen_resolution": "1920x1080",
  "x_ga_mp1_vp": "1920x866",
  "x_ga_mp1_je": "0",
  "x_ga_mp1_jid": "75289892",
  "x_ga_mp1_gjid": "2061012404",
  "client_id": "RQqpiKuM+uSEmRZWY8CJcMC0+90vEmBUdzTJRyMXlM=.1603993594",
  "x_ga_measurement_id": "UA-111147971-1",
  "x_ga_gtm_version": "2wgae3PDXX4BG",
  "x_ga_mp1_z": "2079427983",
  "event_name": "page_view",
  "ip_override": "1.2.3.4",
  "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
  "x_ga_path": "j",
  "x_ga_js_client_id": "796605102.1603993594"
}

Important to know that the tag flattens all nested objects with “_” that came from the client. For example:

{
    'test': {
        'gtm': 'tag'
    }
}

Will send in a request like this:

{
    'test_gtm': 'tag'
}

Also, tag changes “-” symbol in keys to “_”.

That has been done because many systems do not work with nested objects and our tag tries to work with all system out of the box. These transformations apply only for event data that comes from the client, if you use the “Additional Options” setting of the tag keys that you fill in will be used without any modification.

How-to use JSON HTTP Request tag

  1. Download custom tag template from https://github.com/gtm-server/json-http-request-tag
  2. Choose the desired GTM Server Side Container and click on Template -> New
GTM template new tag
  1. Import template.tpl file that you download from GitHub on the first step
JSON HTTP TAG import
  1. After tag installation create a new tag and choose “JSON HTTP request”
JSON HTTP tag Create
  1. Choose a trigger for firing this tag (when you need to send a request). For example, you can choose the trigger that you use for firing the GA tag.
  2. Fill “Destination URL” field in tag configuration with the URL to what request will be sent. Save your newly created tag.
JSON HTTP TAG
  1. After publishing your tag, data will be sent to the URL you set, when the trigger will apply.
Fill free to right issues on GitHub or comments to this post with feature requests and questions.