Using sendEventToGoogleAnalytics

I am trying to send a Google Event from within the Data Tag provided by Stape, however I am unsure how to implement the sendEventToGoogleAnalytics function.

Google says to send a single event in Unified Schema format to Google Analytics, but I cannot find any examples of how to format Unified Schema…

sendEventToGoogleAnalytics(event, (response) => {

How should I send the event parameter passed to sendEventToGoogleAnalytics?

Can you describe what exactly you try to achieve?
Why do you need to use Data Tag/Data Client for sending events to GA? This tag was made for sending data to other systems. For example, for sending Data to FB or Klavio.

For sending events to GA, you can use GA tag/GA client.

I am trying to send an event to Google Analytics when sending data to 3rd party system fails. We have noticed a drop in conversions since moving to Server To Sever and I am trying to collate date in order to diagnose the issue.

Nice question. In the google documentation “Unified Schema” I think they speak about Measurement Protocol v2

And here is an example of sending a request to GA using it

Even in case, I am wrong and “Unified Schema” is some other object. You can use Measurement Protocol v2 and sendHttpRequest function Server-side tagging APIs  |  Google Tag Manager - Server-Side for sending data to GA.

If you find out what exactly “Unified Schema” is, please send the info here.

I tested and look like “Unified Schema” is Common event data  |  Google Tag Manager - Server-Side
In any way it look similar too MP v2 :slight_smile:

Yes I just managed to get it working, I spent ages trying to find out what Unified Schema meant, then simply tried passing data in as an object.

If anyone else wants to use this, code below (obviously you can pass values in event data)…

const gaEvent = {
        'x-ga-measurement_id': 'UA-*********',
        'v': 1,
        't': 'event',
        'cid': event.guid,
        'ea': 'tracking',
        'ec': 'serverToServer',
        'el': 'Cake Conversion Failed'
      sendEventToGoogleAnalytics(gaEvent, (response) => {
1 Like