Skip to content

Set Up Commerce Connect

⏱ 30 minutes intermediate
📜Corecommerce

Commerce Connect sits between Optimizely and your external commerce platform. A correctly configured connector ensures product data flows reliably, content editors see accurate catalog information, and transactional operations route properly to your commerce backend. Poor setup leads to stale product data, broken checkout flows, and frustrated editors.

This guide walks through the complete setup process: installing the connector, configuring authentication, mapping data fields, setting up sync schedules, and verifying the integration.

  1. Install the Commerce Connect package
  2. Configure connector authentication
  3. Map product data fields
  4. Set up sync schedules
  5. Verify the data pipeline

Add the Commerce Connect NuGet package to your Optimizely project.

Install Commerce Connect
bash
dotnet add package Optimizely.CommerceConnect
dotnet add package Optimizely.CommerceConnect.Shopify  # or your platform

Register the connector in your application startup.

Register Commerce Connect
csharp
public void ConfigureServices(IServiceCollection services)
{
    services.AddCommerceConnect(options =>
    {
        options.Platform = CommercePlatform.Shopify;
        options.SyncInterval = TimeSpan.FromMinutes(15);
        options.EnableTransactionProxy = true;
    });
}

Each connector needs credentials to communicate with your commerce platform’s API.

appsettings.json
json
{
  "CommerceConnect": {
    "Platform": "Shopify",
    "ApiUrl": "https://your-store.myshopify.com/admin/api/2024-01",
    "ApiKey": "your-api-key",
    "ApiSecret": "your-api-secret",
    "AccessToken": "your-access-token",
    "WebhookSecret": "your-webhook-secret"
  }
}

Store sensitive values like API keys in environment variables or a secrets manager rather than in configuration files.

Commerce Connect needs to know how fields in your external platform map to Optimizely content properties. Define a mapping configuration for products, categories, and variants.

Data mapping configuration
csharp
services.AddCommerceConnect(options =>
{
    options.ProductMapping = new DataMapping
    {
        // External field -> Optimizely property
        Fields = new Dictionary<string, string>
        {
            ["title"] = "Name",
            ["body_html"] = "Description",
            ["vendor"] = "Brand",
            ["product_type"] = "Category",
            ["handle"] = "UrlSlug",
            ["published_at"] = "PublishDate"
        },
        ImageMapping = new ImageMapping
        {
            SourceField = "images",
            UrlProperty = "src",
            AltProperty = "alt"
        }
    };

    options.VariantMapping = new DataMapping
    {
        Fields = new Dictionary<string, string>
        {
            ["sku"] = "Code",
            ["price"] = "ListPrice",
            ["compare_at_price"] = "OriginalPrice",
            ["inventory_quantity"] = "StockQuantity",
            ["weight"] = "Weight"
        }
    };

    options.CategoryMapping = new DataMapping
    {
        Fields = new Dictionary<string, string>
        {
            ["title"] = "Name",
            ["handle"] = "UrlSlug",
            ["body_html"] = "Description"
        }
    };
});

For custom fields that do not have a direct mapping, implement a transform function.

Custom field transform
csharp
options.ProductMapping.Transforms.Add(
    new FieldTransform
    {
        SourceField = "tags",
        TargetProperty = "SearchTags",
        Transform = (value) =>
        {
            // Convert comma-separated tags to array
            var tags = value?.ToString()
                .Split(',', StringSplitOptions
                    .RemoveEmptyEntries)
                .Select(t => t.Trim())
                .ToArray();
            return tags ?? Array.Empty<string>();
        }
    });

Configure how frequently product data syncs from your commerce platform into Optimizely.

Sync typeTriggerUse case
Scheduled full syncTimer (every 15-60 min)Catches all changes including bulk updates
Webhook real-time syncCommerce platform eventImmediate updates for product publishes
Manual syncAdmin actionOn-demand after bulk imports
Configure sync modes
csharp
services.AddCommerceConnect(options =>
{
    // Full sync every 30 minutes
    options.FullSyncInterval = TimeSpan.FromMinutes(30);

    // Enable webhook for real-time updates
    options.EnableWebhooks = true;
    options.WebhookEndpoint = "/api/commerce-connect/webhook";

    // Sync only published products
    options.SyncFilter = (product) =>
        product.Status == "active";

    // Handle sync errors
    options.OnSyncError = (error) =>
        _logger.LogError(error,
            "Commerce Connect sync error");
});

After configuration, verify that products flow correctly from your commerce platform into Optimizely.

  1. Trigger a manual sync from the Optimizely admin panel under Commerce Connect settings
  2. Check the sync log for errors — common issues include authentication failures, field mapping mismatches, and rate limiting
  3. Browse the CMS catalog to confirm products appear with correct names, descriptions, and images
  4. Query Graph to verify products are indexed and searchable
  5. Test a transaction by adding a product to cart and verifying the operation routes to your commerce platform
Verification stepWhat to checkCommon issues
Sync logNo errors in last sync runAPI credentials expired, rate limits hit
CMS catalogProducts visible with correct dataField mapping errors, missing required fields
Graph explorerProducts queryable via GraphQLSync not triggering Graph re-index
Cart operationAdd-to-cart succeedsTransaction proxy misconfigured
Webhook deliveryReal-time updates arriveWebhook URL not accessible, secret mismatch
ProblemCauseFix
Products not syncingAPI credentials invalidRegenerate and update credentials
Missing product imagesImage URL mapping incorrectVerify the ImageMapping.UrlProperty path
Stale pricingWebhook not configuredEnable webhooks or reduce sync interval
Graph not updatingCMS publish not triggering syncVerify Graph integration is active