From 7154af800dd30750efb256701adfc729d8728a0c Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Tue, 21 Jul 2026 14:13:43 +0700 Subject: [PATCH 1/3] docs: document campaign analytics context --- .../analytics/examples/rudderstack.md | 20 ++++++++++++++++++ content/docs/campaigns/analytics/index.mdx | 21 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/content/docs/campaigns/analytics/examples/rudderstack.md b/content/docs/campaigns/analytics/examples/rudderstack.md index 379c7a16..dfef3332 100644 --- a/content/docs/campaigns/analytics/examples/rudderstack.md +++ b/content/docs/campaigns/analytics/examples/rudderstack.md @@ -62,6 +62,26 @@ RudderStack events follow the Segment specification. The SDK automatically maps | `dl_add_payment_info` | `Payment Info Entered` | Fired when payment information is provided | | `dl_purchase` | `Order Completed` | Fired when an order is successfully completed | +## Campaign and Journey Context + +RudderStack events include the campaign context provided by the SDK using the original snake_case field names: + +| Field | Description | +| --- | --- | +| `campaign_id` | Campaign ID | +| `campaign_name` | Campaign name | +| `campaign_currency` | Campaign currency | +| `campaign_language` | Campaign language | +| `campaign_session_id` | Campaigns session ID | +| `page_type` | Current funnel page type | +| `page_name` | Current funnel page name | + +The adapter also uses the SDK session ID to connect events across the funnel: + +- `Product Added`, `Product Removed`, and `Cart Viewed` include `cart_id`. +- Checkout step, payment, and completed-order events include `checkout_id`. +- Checkout and completed-order events include `coupon` and `discount` when those values are present. + ## Product Format Products are automatically converted to the Segment specification format. Each product in your events will be transformed to include these standardized properties: diff --git a/content/docs/campaigns/analytics/index.mdx b/content/docs/campaigns/analytics/index.mdx index a261670b..5ca94683 100644 --- a/content/docs/campaigns/analytics/index.mdx +++ b/content/docs/campaigns/analytics/index.mdx @@ -87,6 +87,12 @@ All events follow GA4-compliant format: event_id: 'sess_123_2_1234567890', event_time: '2025-01-12T10:30:00Z', + campaign_id: '42', + campaign_name: 'Summer Campaign', + campaign_currency: 'USD', + campaign_language: 'en', + campaign_session_id: 'ncsid_abc123', + user_properties: { visitor_type: 'guest', customer_email: 'user@example.com', @@ -119,6 +125,20 @@ All events follow GA4-compliant format: } ``` +### Campaign Context + +The SDK adds campaign context to every analytics event when that data is available. This makes it possible to segment events by campaign and join provider data back to Campaigns App sessions and order attribution. + +| Field | Description | +| --- | --- | +| `campaign_id` | Campaign ID returned by the Campaigns API | +| `campaign_name` | Campaign name | +| `campaign_currency` | Campaign currency | +| `campaign_language` | Campaign language | +| `campaign_session_id` | Session ID from the Campaigns session-tracking cookie | + +Configure the campaign API key before the SDK loads so the SDK can retrieve the campaign record and populate these fields. + ## Testing & Verification ### Enable Debug Mode @@ -276,4 +296,3 @@ window.NextDataLayer; // Enable debug window.NextAnalytics.setDebugMode(true); ``` - From 8cafa3b3b64351fa9534a3c4f78c92e59a295dd2 Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Tue, 21 Jul 2026 16:57:01 +0700 Subject: [PATCH 2/3] docs: clarify Campaigns analytics context --- .../campaigns/analytics/examples/rudderstack.md | 12 ++++++------ content/docs/campaigns/analytics/index.mdx | 14 ++++++++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/content/docs/campaigns/analytics/examples/rudderstack.md b/content/docs/campaigns/analytics/examples/rudderstack.md index dfef3332..5e80d3a9 100644 --- a/content/docs/campaigns/analytics/examples/rudderstack.md +++ b/content/docs/campaigns/analytics/examples/rudderstack.md @@ -64,22 +64,22 @@ RudderStack events follow the Segment specification. The SDK automatically maps ## Campaign and Journey Context -RudderStack events include the campaign context provided by the SDK using the original snake_case field names: +RudderStack events include campaign and page context using the original snake_case field names: | Field | Description | | --- | --- | -| `campaign_id` | Campaign ID | +| `campaign_id` | Campaign ID returned by the Campaigns API | | `campaign_name` | Campaign name | | `campaign_currency` | Campaign currency | | `campaign_language` | Campaign language | -| `campaign_session_id` | Campaigns session ID | +| `campaign_session_id` | Session ID created by Campaigns session tracking | | `page_type` | Current funnel page type | | `page_name` | Current funnel page name | -The adapter also uses the SDK session ID to connect events across the funnel: +The adapter also uses the SDK's internal analytics session ID as a correlation value on selected events: -- `Product Added`, `Product Removed`, and `Cart Viewed` include `cart_id`. -- Checkout step, payment, and completed-order events include `checkout_id`. +- `Product Added`, `Product Removed`, and `Cart Viewed` use it as `cart_id`. +- Checkout step, payment, and completed-order events use it as `checkout_id`. - Checkout and completed-order events include `coupon` and `discount` when those values are present. ## Product Format diff --git a/content/docs/campaigns/analytics/index.mdx b/content/docs/campaigns/analytics/index.mdx index 5ca94683..8022dd5c 100644 --- a/content/docs/campaigns/analytics/index.mdx +++ b/content/docs/campaigns/analytics/index.mdx @@ -125,6 +125,8 @@ All events follow GA4-compliant format: } ``` +`campaign_session_id` comes from Campaigns session tracking and connects activity to Campaigns App reporting. `_metadata.session_id` is generated by the SDK for event ordering and browser-session correlation. They are separate identifiers; the RudderStack adapter uses the SDK identifier for its `cart_id` and `checkout_id` values. + ### Campaign Context The SDK adds campaign context to every analytics event when that data is available. This makes it possible to segment events by campaign and join provider data back to Campaigns App sessions and order attribution. @@ -135,9 +137,17 @@ The SDK adds campaign context to every analytics event when that data is availab | `campaign_name` | Campaign name | | `campaign_currency` | Campaign currency | | `campaign_language` | Campaign language | -| `campaign_session_id` | Session ID from the Campaigns session-tracking cookie | +| `campaign_session_id` | Session ID from the `ncsid` cookie created by [Campaigns session tracking](/docs/campaigns/api#add-session-tracking) | + +Set the campaign API key before the SDK loads so it can retrieve the campaign record and populate these fields: + +```javascript +window.nextConfig = { + apiKey: 'your-api-key' +}; +``` -Configure the campaign API key before the SDK loads so the SDK can retrieve the campaign record and populate these fields. +See [Campaigns configuration](/docs/campaigns/configuration) for the complete setup. If the key is missing, analytics logs a console warning and emits events without the campaign ID, name, currency, or language. The session-tracking ID remains available when the `ncsid` cookie is present. ## Testing & Verification From b8a783ada2c6a6ec8e88a3c888792653702e2ead Mon Sep 17 00:00:00 2001 From: Devin Michael Date: Tue, 21 Jul 2026 17:03:57 +0700 Subject: [PATCH 3/3] docs: label analytics session identifiers --- content/docs/campaigns/analytics/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/campaigns/analytics/index.mdx b/content/docs/campaigns/analytics/index.mdx index 8022dd5c..54f99b9f 100644 --- a/content/docs/campaigns/analytics/index.mdx +++ b/content/docs/campaigns/analytics/index.mdx @@ -91,7 +91,7 @@ All events follow GA4-compliant format: campaign_name: 'Summer Campaign', campaign_currency: 'USD', campaign_language: 'en', - campaign_session_id: 'ncsid_abc123', + campaign_session_id: 'ncsid_abc123', // Campaigns session-tracking ID user_properties: { visitor_type: 'guest', @@ -117,7 +117,7 @@ All events follow GA4-compliant format: }, _metadata: { - session_id: 'sess_abc123', + session_id: 'session_abc123', // SDK analytics session ID sequence_number: 2, source: 'next-campaign-cart', version: '0.2.0'