logo

Advanced Google Tag (gtag.js)

This method of integration is required if your Google Analytics configuration implemented through Google Tag is already sending sending data to a server container. It works by creating a new Google Analytics 4 configuration that is a copy of your original GA4 configuration and will only send data to the SegmentStream server.

SegmentStream admin panel setup

  1. Inside the admin panel navigate to Settings > Google Analytics.
  1. Open the Advanced Settings menu and disable the Forward events to Google Analytics 4 option.
  1. Click on the field containing the Server Container URL to copy its value to your clipboard and click SAVE.
Image without caption

Create new data stream in your Google Analytics 4

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.
  1. Sign in to your Google Analytics account and navigate to the Admin section.
  1. Select the account and property where your current data stream is located.
  1. Under the Property column, click on Data Streams.
    1. Image without caption
  1. Click on the Add Stream button and select Web.
    1. Image without caption
  1. You should see a notice, click yes.
    1. Image without caption
  1. Enter your website's URL and name the stream SegmentStream GA4 Streaming.
    1. Image without caption
  1. Click Create stream.
  1. 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.
    1. Image without caption
  1. Make note of the Measurement ID of your new data stream.
    1. Image without caption

Update your Google Tag implementation

  1. In your website code, find where the Google Analytics 4 gtag config code is implemented.
  1. 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.
  1. The new configuration should have a transport_url parameter that contains the value of the the Server Container URL field found in your SegmentStream project.
  1. See an example of the code below:
    1. javascript
      gtag('config','YOUR-MEASUREMENT-ID',{ 'transport_url': 'SERVER CONTAINER URL', });
  1. Deploy the code to your production server.