Deploy Tracking Script via CMS NuGet Package
Install and configure Content Recommendations tracking for Optimizely CMS 12 websites using the NuGet package integration.
Deploy Tracking Script via CMS NuGet Package
For Optimizely CMS 12 websites, you can set up tracking by installing a NuGet package.
Prerequisites
- An active Content Recommendations subscription.
- An Optimizely CMS 12 website.
- Your site must use
RenderRequiredClientResourcesin the HTML<head>, as this is where the tracking script is injected.
Step 1: Install the NuGet Package
- Add the Optimizely NuGet Feed:
- In Visual Studio, go to Tools > NuGet Package Manager > Package Manager Settings.
- Select Package Manager > Package Sources and click the Add (+) icon.
- Enter a Name (e.g.,
Optimizely) and the Source URL:https://nuget.optimizely.com/feed/packages.svc/. Click OK.
- Install the Package:
- In the Solution Explorer, right-click your project's Dependencies and select Manage NuGet Packages.
- Select the Optimizely package source.
- Browse for
EPiServer.Personalization.Content.UIand click Install. - Rebuild your solution.
Step 2: Configure Tracking in appsettings.json
appsettings.jsonAdd the following configuration block to the EPiServer section of your appsettings.json file. Populate the values with the credentials from your account.
{
"EPiServer": {
"ContentPersonalization": {
"Environment": "your-region.idio.episerver.net",
"ClientName": "your-client-name",
"ClientId": "YOUR_CLIENT_ID",
"ApiToken": "YOUR_API_TOKEN",
"DisableDefaultTracking": false
}
}
}| Key | Description |
|---|---|
Environment | The environment endpoint for your account. |
ClientName | The friendly name of your client account. |
ClientId | The alphanumeric client identifier for your account. |
ApiToken | The token used to authenticate to the API endpoint. |
DisableDefaultTracking | (Optional) Set to true to disable the default tracking script if you use another method like Google Tag Manager. This is critical to prevent duplicate tracking. |
Step 3: Deploy and Validate
Deploy your updated application. To validate the installation, open your website, launch your browser's Developer Tools, and check the Network tab to confirm that requests are being sent to the Content Recommendations service (e.g., filter for idio).
Updated 4 days ago