- Getting started
- Forwarding events to Google Analytics through SegmentStream
- Send events to SegmentStream through a separate GA4 configuration
By using the Google Analytics 4 Streaming connection, you can export data to SegmentStream without any event collection limits, while simultaneously forwarding the data to your Google Analytics 4 property. This is unlike the native GA4 BigQuery export, where the built-in limits could potentially result in loss of optimisation signals.
Getting started
Google Analytics 4 should already be implemented on your website either through Google Tag Manager or directly by using the Google Tag (gtag.js).
Please refer to the Google setup instructions if GA4 has not been set up before proceeding with this guide.
- Inside the admin panel navigate to Settings > Google Analytics.
- Choose Google Analytics 4 Streaming from the list.
- Configure the Referral exclusion list to match your Google Analytics property.
- Edit the Timezone setting if necessary.
- Disable the Anonymize IP option if you would like to collect granular location data.
- Click on the Endpoint field to copy its value to your clipboard and click SAVE.
- Follow the integration guide depending on how you have implemented Google Analytics 4 and whether you plan to use the event forwarding feature or not.
Forwarding events to Google Analytics through SegmentStream
If the Forward events to Google Analytics 4 option is enabled in the SegmentStream panel, all the events sent to the server container will be will be collected by SegmentStream, and then forwarded to the Measurement ID specified in your current GA4 configuration.
If you do not want to collect certain events in Google Analytics 4 or forward any events through SegmentStream, disable the Forward events to Google Analytics 4 option and consult this guide for the setup instructions.
Forwarding using Google Tag Manager (GTM)
- Go to the Tags section in the Google Tag Manager container.
- Open your Google Analytics: GA4 Configuration tag.
- Edit the configuration and select the Send to server container option.
- Paste the Endpoint value of the Google Analytics 4 Streaming connection (Getting started - step 6 of this guide) into the Server Container URL field. Your tag should look like this:
- Click Save.
- Use the GTM Preview functionality to test if the setup is correct before publishing the changes.
- If the Preview container is successfully connected to your website you should see a notification.
- Next, click through a couple of pages on your website to make sure events are being sent to SegmentStream.
- Then, open your Google Analytics settings page in the SegmentStream admin panel.
- If the message is highlighted in red, try clicking on the refresh button.
- If the message persists, it means that data hasn't been collected yet. You should make sure you followed the guide correctly or contact our support team.
-
If you see a message highlighted with green, informing you that data has been collected, you can Publish the GTM container.
Forwarding using Google Tag (gtag.js)
- In your website code, locate the implementation of the Google Analytics 4 tag.
- After finding the line with your current tag, edit it so that it has a transport_url parameter that contains the value of the Endpoint field (Getting started - step 6 of this guide).
- See an example of the code below:
gtag('config', 'YOUR-MEASUREMENT-ID', {
'transport_url': 'ENDPOINT',
}); - Deploy the code to your production server.
Forwarding using Shopify GA4 integration
- From your Shopify admin, got to Online store > Preferences.
- Click Google from the left side menu.
- Copy the ID of the Google Analytics tag, you'll need it in later steps.
- From your Shopify admin, go to Online Store > Themes.
- Click ... > Edit code.
- Open the theme.liquid file.
- Enter the following code in the head of the file, replacing G-XXXXXXXXXX with the ID copied from step 3, and ENDPOINT with the value of the Endpoint field (Getting started - step 6 of this guide).
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());gtag('config', 'G-XXXXXXXXXX', {
transport_url: 'ENDPOINT',
send_page_view: false
});
</script> - The code should look like this.
- Click Save.
Send events to SegmentStream through a separate GA4 configuration
When the Forward events to Google Analytics 4 option is disabled in the SegmentStream panel, all the events sent to the server container will only be collected by SegmentStream.
To collect data in both GA4 and SegmentStream simultaneously, you will need to create a new data stream in the GA4 interface. Please follow this guide for detailed instructions.
- Sign in to your Google Analytics account and navigate to the Admin section.
- Select the account and property where your current data stream is located.
- Under the Property column, click on Data Streams.
- Click on the Add Stream button and select Web.
- You should see a notice, click yes.
- Enter your website's URL and name the stream SegmentStream GA4 Streaming.
-
Click Create stream.
-
Any custom events and event modifications specified in the settings of the current data stream need to be duplicated in the newly created SegmentStream GA4 Streaming stream.
- Make note of the Measurement ID of your new data stream.
Setup using Google Tag Manager (GTM)
- Go to the Tags section in the Google Tag Manager container.
- Open your Google Analytics: GA4 Configuration tag and copy it.
- Rename the copied tag to GA4 Streaming Configuration.
- Set the Measurement ID field to the value from the newly created SegmentStream GA4 Streaming data stream.
- Select the Send to server container option.
- Paste the Endpoint value of the Google Analytics 4 Streaming connection (Getting started - step 6 of this guide) into the Server Container URL field, and click Save.
-
Copy all the Google Analytics: GA4 Event tags.
-
Rename the copied event tags using the format GA4 Streaming - {event name}.
-
Set the Configuration Tag option of all copied event tags to GA4 Streaming Configuration.
- Use the GTM Preview functionality to test if the setup is correct before publishing the changes.
- If the Preview container is successfully connected to your website you should see a notification.
- Next, click through a couple of pages on your website to make sure events are being sent to SegmentStream.
- Then, open your Google Analytics settings page in the SegmentStream admin panel.
- If the message is highlighted in red, try clicking on the refresh button.
- If the message persists, it means that data hasn't been collected yet. You should make sure you followed the guide correctly or contact our support team.
-
If you see a message highlighted with green, informing you that data has been collected, you can Publish the GTM container.
Setup using Google Tag (gtag.js)
- In your website code, find where the Google Analytics 4 gtag config code is implemented.
- Create a new configuration next to the current configuration and set the Measurement ID field to the value from the newly created SegmentStream GA4 Streaming data stream.
- The new configuration should have a transport_url parameter that contains the value of the Endpoint field (Getting started - step 6 of this guide).
- See an example of the code below:
gtag('config','YOUR-MEASUREMENT-ID',{
'transport_url':'ENDPOINT',
}); - Deploy the code to your production server.
Comments
0 comments
Please sign in to leave a comment.