Sending data from a website using on-site gtag.js code

The Google tag (gtag.js) is a single tag you can add to every page of your website and use gtag() commands to send data to Google products (e.g. Google Analytics 4). OWOX BI GA4 events-based streaming supports sending data via gtag.js. In this article, we describe two options for customizing the Google tag.

ImportantYou need access to the HTML for your web pages. Ask your web developer to perform these steps if you're unable to complete the steps yourself.

 

Option #1. Data is collected simultaneously in both Google Analytics 4 and OWOX BI GA4 events-based web streaming to Google BigQuery

Step 1. Following this instruction, create a new web stream 'OWOX BI Stream' in Google Analytics 4 settings. In the next step, you will need the ’MEASUREMENT ID’ of this stream.

Step 2. Find each page of your website where you use the gtag config command. Add one more gtag ('config') command with the parameter 'transport_url'. As a value of this parameter specify the link to the OWOX BI access point received from the OWOX manager (bi@owox.com):

gtag('config', 'G-XXXXXX-2', { 
	'transport_url': 'https://streaming.bi.owox.com/ga4/...',
	'groups': 'owox'
});

Replace 'G-XXXXXX-2' with the ’MEASUREMENT ID’ of the new ‘OWOX BI Stream’.

Replace 'https://streaming.bi.owox.com/ga4/...' with the full URL.

Note We also recommend using the 'groups' parameter. This will help you with sending custom events in the next step.

So you should get something like this:

gtag('config', 'G-XXXXXX-1', { 
	'groups': 'ga'
});

gtag('config', 'G-XXXXXX-2', { 
	'transport_url': 'https://streaming.bi.owox.com/ga4/...',
	'groups': 'owox'
});

First (default) gtag config:

  • Replace 'G-XXXXXX-1' with a ‘MEASUREMENT ID of your default stream in Google Analytics 4 settings.
  • Add parameter 'groups' with value 'ga'.

Second gtag config:

  • Should be added below after the default gtag config command.
  • And this gtag has two parameters: 'transport_url' and 'groups'.

 

Step 3 (Optional). If you send custom events to Google Analytics 4, then you should start sending these custom events to the web stream ‘OWOX BI Stream’ which you created in the first step. To do this, add the parameter 'send_to' to each custom event. As a value of this parameter write webstream ‘MEASUREMENT ID’:

gtag('event', 'generate_lead', { 'send_to': 'G-XXXXXX-2' });

or specify group name (from gtag config):

gtag('event', 'generate_lead', { 'send_to': ['owox'] });

Recommended method: send event data to the specified group. You should get something like this:

gtag('config', 'G-XXXXXX-1', { 
	'groups': 'ga'
});

gtag('config', 'G-XXXXXX-2', { 
	'transport_url': 'https://streaming.bi.owox.com/ga4/...',
	'groups': 'owox'
});

gtag('event', 'generate_lead', { 'send_to': ['ga','owox'] });
gtag('event', 'login', { 'send_to': ['ga','owox'], 'user_id': 1, 'room': 'public' });
gtag('event', 'logout', { 'send_to': ['ga','owox'] });

 

Step 4. Save all changes and deliver them to the server from which your site is loaded. Data collection may take up to 30 minutes to begin.

 

Option #2. Data is collected ONLY into OWOX BI GA4 events-based web streaming to Google BigQuery and is not streamed to Google Analytics 4

Step 1. To the existing gtag config command add the 'transport_url' parameter. As a value of this parameter specify the link to the OWOX BI access point received from the OWOX manager (bi@owox.com):

gtag('config', 'G-XXXXXX-1', { 
	'transport_url': 'https://streaming.bi.owox.com/ga4/...'
});

Replace 'G-XXXXXX-1' with the 'MEASUREMENT ID' of your default stream in Google Analytics 4 settings.
Now all events will only be sent to the OWOX BI access point and will no longer be sent to Google Analytics.

 

Step 2. Save the changes and deliver them to the server from which your site is loaded. Data collection may take up to 30 minutes to begin.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.