Deploy tracking script with CMS NuGet package
4 min
For Optimizely Content Management System (CMS) 12 websites, you can set up tracking by installing a NuGet package.
Prerequisites
- Have an active Content Recommendations subscription.
- Have an Optimizely CMS 12 website.
- Use RenderRequiredClientResources in the HTML <head>, as this is where the tracking script is injected.
Install the NuGet package
Add the Optimizely NuGet feed
- Open 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
- Go to Solution Explorer.
- Select Dependencies from Manage NuGet Packages drop-down list.
- Select the Optimizely package source.
- Browse for EPiServer.Personalization.Content.UI and click Install.
- Rebuild your solution.
Configure tracking in appsettings.json
Add 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
}
}
}- 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) Used to disable the default tracking script if you use another method like Google Tag Manager. Set to true to prevent duplicate tracking.
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 (for example, filter for idio).