How do I integrate CRM or backend system conversions with Convert?

This guide will outline how to gather visitor data—including session IDs, experiment variations, segments, goals, and the experiments the visitor is part of—and relay this information back to Convert.com using Zapier.

Step 1: Gather Comprehensive Visitor Experiment Data

To capture the necessary visitor experiment data, you’ll need to implement Convert’s tracking code on your site. This code captures key details such as session ID, variation IDs, user segments, goals, and experiments that each visitor participates in.

  1. Install the Convert Tracking Code: Embed the Convert tracking code within the <head> section of your website HTML. This ensures all visitors are tracked as intended.

  2. Create Custom Fields in Your CRM: In your CRM (e.g., Keap), create custom fields to store visitor data:

    • ConvertExperiments: List of experiments a visitor is part of.
    • ConvertVariations: Variation IDs for each experiment.
    • SessionID: Session identifier.
    • Segments: Visitor segments.
  3. Implement JavaScript to Capture Data: Use JavaScript to collect data from Convert and populate the CRM fields once the form loads:

    javascript
    Copy code
    window._conv_q = window._conv_q || [];
    window._conv_q.push({
    what: 'addListener',
    params: {
    event: 'snippet.experiences_evaluated',
    handler: function() {
    let session_cookie = convert.getCookie('_conv_s');
    if (!session_cookie) {
    console.error('Session cookie not found.');
    return;
    }
    let session_id = session_cookie.substring(
    session_cookie.indexOf('sh:') + 3,
    session_cookie.indexOf('*')
    );
    let exp_list = [];
    let variation_list = [];
    let goals_data = convert.currentData.goals || {};

    function processExperiences(sourceData) {
    for (let expID in sourceData) {
    let experience = sourceData[expID];
    let variation = experience.variation || {};
    let varID = variation.id || experience.variation_id;

    if (varID && !exp_list.includes(expID)) {
    exp_list.push(expID);
    variation_list.push(varID);
    console.log('Adding experiment:', expID, 'with variation:', varID);
    }
    }
    }

    if (convert.currentData && convert.currentData.experiences) {
    processExperiences(convert.currentData.experiences);
    }

    // Wait until the form is loaded
    document.addEventListener("DOMContentLoaded", function() {
    // Populate CRM form fields with collected data
    document.getElementById('_ConvertExperiments').value = exp_list.join(',');
    document.getElementById('_ConvertVariation').value = variation_list.join(',');
    document.getElementById('_SessionID').value = session_id;
    document.getElementById('_UserSegments').value = JSON.stringify(convert.getDefaultSegments());
    document.getElementById('_Goals').value = JSON.stringify(goals_data);

    console.log('Form fields populated with data:', {
    variation: variation_list.join(','),
    session: session_id,
    segments: convert.getDefaultSegments(),
    goals: goals_data,
    experiments: exp_list.join(',')
    });
    });
    }
    }
    });
  4. Embed and Test the Form: Publish a web form on your website with hidden fields (matching IDs to those used in JavaScript). Submit a test form to verify all custom CRM fields are populated correctly.

Step 2: Send Visitor Data to Zapier via Webhook

With your CRM capturing visitor data, set up a webhook to send this data to Zapier.

  1. Set Up a Webhook in Your CRM: Configure your CRM to trigger a webhook upon form submission or conversion. The webhook should send an HTTP POST request to Zapier, including the visitor data fields (session ID, experiment IDs, variation IDs, and goals).

  2. Create a Zap in Zapier: In Zapier, create a Zap triggered by the webhook sent from your CRM.

  3. Map Data Fields: Within Zapier, map the incoming CRM data fields (like session ID, goals, variation IDs, and experiment IDs) to a structured JSON format required by Convert. Here’s a sample JSON format you’ll need:

    json
    Copy code
    {
    "cid": "YOUR_ACCOUNT_ID",
    "pid": "YOUR_PROJECT_ID",
    "seg": {
    "browser": "CH",
    "devices": ["DESK"],
    "source": "direct",
    "campaign": "",
    "new": 1,
    "ctry": "RO",
    "cust": ["123", "456"]
    },
    "vid": "SESSION_ID", // Replace with CRM field data
    "ev": [
    {
    "evt": "viewExp",
    "vars": ["VARIATION_ID_1", "VARIATION_ID_2"],
    "exps": ["EXPERIMENT_ID_1", "EXPERIMENT_ID_2"]
    },
    {
    "evt": "hitGoal",
    "goals": [GOAL_ID],
    "vars": ["VARIATION_ID_1", "VARIATION_ID_2"],
    "exps": ["EXPERIMENT_ID_1", "EXPERIMENT_ID_2"]
    }
    ]
    }
  4. Relay Webhook to Convert: In the Zapier webhook setup, set the method to “POST” and configure the URL to https://YOUR_PROJECT_ID.metrics.convertexperiments.com/track. This will ensure Zapier sends the collected data to Convert as per the required format.

  5. Test and Activate the Zap: Run tests in Zapier to ensure that data relays correctly to Convert. Once confirmed, activate your Zap for automatic, ongoing data transfers.

Conclusion

Following these steps, you’ll have a robust integration that captures detailed visitor data, automatically sending it from your CRM to Convert via Zapier. This integration enhances tracking capabilities, providing insights into user behavior and conversion events effectively.