Skip to content
  • There are no suggestions because the search field is empty.

Get Variations Without Registering a View in Convert Full Stack SDK

Use Convert Full Stack SDK to retrieve variations without triggering view events—ideal for pre-assembled UIs in apps like React Native.

🚀 IN THIS ARTICLE YOU WILL:

🔍 Overview

This article explains how to retrieve variations from the Convert Full Stack SDK without registering a view event, which is particularly useful for applications that need to pre-assemble components before displaying them to users.

⚠️ Problem Statement

When implementing A/B testing in applications that pre-assemble screens or components before displaying them to users (common in React Native applications), developers face two challenges:

  • Inefficient Request Flow: Sending a request on every screen navigation and waiting for a response causes either loading states or screen flickers.

  • Premature View Registration: Getting variations automatically registers a view event in Convert, even though the user may never actually see that variation.

🛠 Solution: Disable Tracking When Getting Variations

The Convert Full Stack JavaScript SDK provides a flag to disable tracking when retrieving variations:

// Get variations without registering a view event
context.runExperience('experience-key', { 
  enableTracking: false 
});

// OR for multiple experiences
context.runExperiences({ 
  enableTracking: false 
});

🛠 Implementation Workflow

Pre-assembly Phase: Get Variations Without Tracking

// Get variation data without registering a view
const variationData = await context.runExperience('experience-key', { 
  enableTracking: false 
});

// Pre-assemble components using the variation data
const assembledComponent = assembleComponent(variationData);

Display Phase: Register the View Event When the User Actually Sees the Content

You have two options:

Option 1: Call the Same Methods with Tracking Enabled

When the component is actually displayed to the user, call the same method but with tracking enabled (default behavior):

// When the user actually sees the component, call runExperience again with default tracking
// This uses the same user context, so the same variation will be returned and properly tracked
context.runExperience('experience-key');  // enableTracking defaults to true

// OR for multiple experiences
context.runExperiences();  // enableTracking defaults to true

Option 2: Use Convert's Tracking API

Alternatively, use Convert's tracking API to manually send the view event:

// Use Convert's tracking API to manually register the view event
// Documentation: https://api.convert.com/doc/serving/#tag/Experiences-Tracking/operation/sendTrackingEvents
// Example implementation (specific implementation details would depend on your setup)
fetch('https://api.convert.com/tracking/events', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    experienceKey: 'experience-key',
    visitorId: 'visitor-id',
    eventType: 'bucketing'  // For view/bucketing events
  })
});

You can find the documentation for sending tracking events here.

📖 Best Practices

  • Performance Optimization: Use this approach when pre-assembly is necessary for performance reasons.

  • Accurate Analytics: Ensure view events are properly registered when content is actually displayed.

  • Consistent Variations: Use the same user context for both the untracked and tracked calls to maintain consistency.

📚 Related Resources