Cross-Domain Usage Guide

The Telemetry Web SDK allows users to track their journey across multiple domains by sharing the same journey ID and client ID. This is achieved by getting an access token on the initial domain and passing it to subsequent domains.

This guide explains how to use the SDK to maintain the same journey ID and client ID across different domains.

Steps to Implement

1. Initialize Telemetry Web SDK on Domain A

  • Start by initializing the SDK on Domain A.

  • Before navigating away from Domain A, call the YofiTelemetry.getAppAccessToken method to generate an access token.

// Get access token before navigation
const accessToken = await YofiTelemetry.getAppAccessToken();

2. Pass the Access Token to Domain B

Transfer the generated access token to Domain B. This can be done via URL parameters, cookies, or any other method suitable for your application.

Example using URL parameters:

<a href="https://domain-b.com?accessToken=YOUR_ACCESS_TOKEN">Go to Domain B</a>

3. Initialize Telemetry Web SDK on Domain B

On Domain B, initialize the SDK and pass the received access token during initialization.

// Extract access token from URL or other source
const urlParams = new URLSearchParams(window.location.search);
const accessToken = urlParams.get('accessToken');

// Initialize the SDK with the access token
YofiTelemetry.init({
  publicToken: 'your-public-token', 
  journeyIdSalt: 'your-value'
  accessToken: accessToken,
  // Other initialization options
});

Conclusion

By following these steps, you can ensure that the same journey ID and client ID are used across different domains, providing a seamless tracking experience for users. For further details and advanced configurations, please refer to this Quick Start.

Last updated

Was this helpful?