Skip to main content

Segment Integration

The Segment integration in Consent Manager manages user consent for the Segment tracking script in your application. It directly injects the Segment Analytics.js script once the user consents.

Warning: Using Segment can lead to increased loading times and potential loss of control over tracking and script management, similar to Google Tag Manager. It's important to use it judiciously and understand its impact on performance and privacy.

TitleSegment
IDsegment
IconSegment
Brand color#52BD94
Contrast color#000
DescriptionWe use Segment to improve your browsing experience.
Privacy policyhttps://segment.com/legal/privacy/
WrapperComponent
Enabled by default⛔️

Configuration Options

  • writeKey: Your Segment write key.

getSegment Function

The getSegment function provides access to the initialized Segment instance. This enables you to interact with Segment's tracking functionalities within your application.

Example Usage with Segment's API

Here's how you might use the getSegment function to integrate and manage Segment in your React application:

import { useEffect } from 'react';
import { getSegment } from '@consent-manager/integration-segment';

function App() {
useEffect(() => {
const segment = getSegment();
if (segment) {
// Utilize Segment functionalities
// segment.track(...), segment.identify(...), etc.
}
}, []);

// Your application content
return (
// ...
);
}

export default App;