Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.segmentstream.com/llms.txt

Use this file to discover all available pages before exploring further.

The SegmentStream SDK adds a first-party measurement layer alongside GA4. It preserves ad platform click IDs during internal navigation, sends cookieless pings to SegmentStream, and can send conversion events through segmentstream.conversion().

What the SDK does

  • Click ID propagation: preserves ad platform click IDs, such as gclid, fbclid, ttclid, msclkid, li_fat_id, ScCid, rdt_cid, twclid, dclid, and epik, across internal links, window.open, and History API navigation.
  • Cookieless pings: sends page-load and first-interaction pings to SegmentStream without relying on analytics cookies.
  • Conversion tracking: sends direct conversion events from the website through segmentstream.conversion().

Installing the SDK via GTM

1

Create a new tag

In Google Tag Manager, go to Tags and click New.GTM Tags page with New button
2

Configure the tag

Name the tag SegmentStream SDK and choose the Custom HTML tag type.Selecting Custom HTML tag type
3

Add the SDK code

Enter the following code. Replace ID PROVIDED BY MANAGER with the ID provided by your SegmentStream account manager.
<script>(function(){var s=window.segmentstream=window.segmentstream||{};
s._q=s._q||[];['init','conversion','anonymousId'].forEach(function(m){
s[m]=function(){s._q.push([m,Array.prototype.slice.call(arguments)])}})})();</script>

<script async src="https://cdn.segmentstream.com/sdk/v1/segmentstream.min.js"></script>
<script>segmentstream.init("ID PROVIDED BY MANAGER");</script>
4

Set firing options

Expand Advanced Settings and select Once per page in Tag firing options.
5

Add a trigger

Choose All Pages in the Firing Triggers option.SDK tag with All Pages trigger

Configuring SDK settings

By default, the SegmentStream SDK enables click ID propagation and cookieless pings. Browser storage is disabled unless you explicitly enable it. Available settings:
SettingDefaultDescription
click_id_propagationtruePreserves ad platform click IDs across internal links, window.open, and History API navigation.
cookieless_pingstrueSends page-load and first-interaction pings to SegmentStream without relying on analytics cookies.
local_storagefalseEnables localStorage for attribution touchpoints and conversion deduplication state.
Add the settings block before the SDK script only when you need to override the defaults:
<script>
  window.segmentstream_sdk_settings = {
    click_id_propagation: true,
    cookieless_pings: true,
    local_storage: false
  };
</script>
Enable local_storage only when your consent and privacy setup allows browser storage. When local_storage is false, the SDK does not store attribution touchpoints or conversion deduplication state in the browser.

Aggregated conversions measurement

The SegmentStream SDK supports conversion tracking through a strict object API. Use it when you need SegmentStream to receive a direct conversion signal from the website, such as a purchase, lead, signup, or subscription.

Implementation through GTM

1

Create a new tag

In Google Tag Manager, go to Tags, click New, name the tag SegmentStream Conversion Tracking, and choose the Custom HTML tag type.
2

Add the conversion code

In the HTML block, insert the appropriate code for your conversion type:
Replace ORDER_ID and ORDER_VALUE with the variables used in your GA4 conversion tag.
<script>
segmentstream.conversion({
  type: 'purchase',
  id: 'ORDER_ID',
  value: ORDER_VALUE,
  currency: 'USD'
});
</script>
Conversion tracking tag configuration
3

Set the trigger

Set the trigger for this tag to match the trigger used by your GA4 conversion tag.
4

Configure tag sequencing

In Tag Sequencing, make sure the SegmentStream SDK tag fires before this tag.
5

Save and publish

Save and publish the changes.

Implementation via SDK

You can trigger a conversion directly using the SDK method:
segmentstream.conversion({
  type: 'purchase',    // Required: event type, such as 'purchase', 'lead', or 'signup'
  id: 'ORDER_ID',      // Optional: unique identifier for the conversion
  value: ORDER_VALUE,  // Optional: numeric value of the conversion
  currency: 'USD'      // Optional: currency code
});
Examples:
segmentstream.conversion({
  type: 'purchase',
  id: 'ORD-12345',
  value: 199.99,
  currency: 'USD'
});
This function should be called on the conversion confirmation page, such as the order success or thank-you page, after the SegmentStream SDK is initialised.

Sending lead data to your CRM

When sending lead data from your website to your CRM, pass the user identifier provided by the SegmentStream SDK instead of using the _ga cookie value:
window.segmentstream.anonymousId()
  • If the user has consented to cookies, this method returns the _ga cookie value.
  • If the user has not consented, it returns a generated anonymous ID (instead of null).
This approach ensures that SegmentStream’s aggregated attribution works for both consented and non-consented users. How to implement:
  1. If your CRM currently receives the _ga cookie value, replace it with window.segmentstream.anonymousId().
  2. If replacement is not possible, send the anonymousId() value to a separate field in your CRM.
  3. On the same page where the lead is sent to the CRM, call window.segmentstream.conversion({ type: 'lead' }).
Calling the conversion method on a different page (for example, a redirect page after the lead is sent) will not work for aggregated conversion attribution. The call must happen on the same page where the lead is submitted.
// Send data to the CRM
const clientId = window.segmentstream.anonymousId();
sendLeadToCRM({
    name: leadName,
    email: leadEmail,
    clientId: clientId
});

// Send data to SegmentStream
window.segmentstream.conversion({
    type: 'lead'
});

Verifying the SDK

1

Confirm the SDK ping

After page load, open the browser Network tab and look for a POST request to https://track.segmentstream.com/ds/PROJECT_ID with eventName: "ping".
2

Confirm click ID propagation

Open a page with a test click ID, such as ?gclid=test, then click an internal link. The click ID should remain in the URL after navigation.
3

Confirm conversion tracking

Trigger the conversion action and look for a POST request to https://track.segmentstream.com/ds/PROJECT_ID with eventName: "conversion" and conversionEventName matching the type value you passed to segmentstream.conversion().
4

Check the console

The browser console should not show SegmentStream errors. If you see SDK must be initialized with project_id, check that segmentstream.init("ID PROVIDED BY MANAGER") runs before conversion tracking.