Stape

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

Updated
Nov 24, 2021
Published
Nov 25, 2020

A common issue for data analytics and sales managers is the accurate tracking of user behavior and conversions. And often, they might face a problem that seems to have no solution. Or alternatively, there are no developers who can do this, and the next update of the site is planned only for next month.

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

So what is the correct solution?Copy link to this section

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, it is enough. That is if all data from the event can be sent in JSON Body to the desired URL. And that is why we created a JSON HTTP request tag.

JSON HTTP Request tag for GTM Server SideCopy link to this section

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 the Community Template Gallery and expect that it will be shown on it after Google turns 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://stape.io/", "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"

It is 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 is done because many systems do not work with nested objects and our tag tries to work with all systems out of the box. These transformations apply only to event data that comes from the client. If you use the “Additional Options” setting of the tag, the keys that you fill in will be used without any modification.

How-to use JSON HTTP Request tagCopy link to this section

1. Add custom tag template from the Server template galleryhttps://tagmanager.google.com/gallery/#/owners/gtm-server/templates/json-http-request-tag.

2. Choose the desired GTM Server Side Container and add it to the workspace.

json http reuqest tag

3. Another option is to click templates inside the server container ->  Search Gallery -> addJSON HTTP request by stape.io.

4. After tag installation, create a new tag and choose “JSON HTTP request”

5. 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.

6. Fill “Destination URL” field in tag configuration with the URL your request will be sent to and save your newly created tag.

json http request create tag

7. After publishing your tag, data will be sent to the URL you set, when the trigger applies. 

Feel free to tell about the issues on GitHub or in the comments to this post with feature requests and questions.

Got confused?

Just tell us what the problem is. Click Get help, fill up the form, and we will send you a quote.

Get help
Tagged with:Google Analytics

Relevant posts

Updated Oct 24, 2022

3 Easy Steps to Test Server-Side Universal Analytics/GA4 and Facebook Conversion API

Google released a Server-Side version of Google Tag Manager in 2020. Server-side tracking is more complicated than the web container set up, at least for now, since the idea and technology behind server tagging are entirely different from what we used to have on the web. But server-side tagging will give your site huge benefits. Server-side tagging is getting more popular due to its ability to track people using AdBlockers, browsers with ITPs, and other tracking restrictions. The purpose of this article is not to convince you to start using server-side tagging (there is another blog post that describes the main benefits of server-side tracking). I assume that you’ve already decided to implement server-side tagging on your site. This blog post will show you how to check whether Server-Side tracking for Universal Analytics, GA4, and Facebook conversion API was set up correctly.

Updated Feb 23, 2024

Google tag manager server-side: How to set up server Tag Manager, Universal Analytics, GA4, and Facebook conversion API

Server-side tagging has been one of the main trends in web analytics for the last couple of years. Ad blockers, Intelligent Tracking Protection, 3rd party cookie restrictions, regulations like GDPR made analytics and advertising companies start worrying about how and what information they collect about site visitors. Server-side tagging allows moving third-party tags off your site and into a cloud server. In this case, third-party pixels are loaded directly from the could server rather than your site. In this article, I will explain and demonstrate the basics of setting up Google Tag Manager server container, server Universal Analytics, GA4, and Facebook Conversion API.

Updated Oct 24, 2022

How to prevent your Google Analytics data from being blocked by ad blockers

You’ve probably noticed that data about your website users and conversions collected by different analytics tools might vary. Most of the time, you’ll see that the purchase number in Google Analytics is lower than in your CRM. Where this data discrepancy comes from, why is it happening, and how to fix it?

Host your GTM server at Stape