Back

The China CDN Deployment Extension is a Pre Loader extension that runs before the Data Layer Processing. This extension determines a user's location (inside or outside China), which allows web site content to be sent to the user from the appropriate CDN. You can use this extension when you cannot modify the source code for a web site to add logic to determine the user's location.

In this article:

Table of Contents Placeholder

Prerequisites

How it Works

The China CDN Deployment Extension consists of a code editor pre-filled with JavaScript code that is executed during the pre-loader scope. This code contains logic to do the following:

  • Determine the users location based on the users browser language, timezone, and IP address.
  • Set a cookie with the best CDN for that user.

All subsequent site visits read the cookie value, if it is present, and fetch all utag content from the most specified CDN. Setting the cookie in the pre-loader scope means that the initial page request is served from the appropriate CDN.

Configuring the Extension

When you add the China CDN Deployment Extension to a profile, an Ace Editor window is displayed, which contains the default code for the extension. You can configure the domainMap, languageMap, and gmtMap variables for the extension.  In addition, you can specify the matchLogic to determine a user's location.

Setting Up Domain Mapping

If you have multiple domains associated with a profile, you can use the domainMap to direct all domain traffic to a specific CDN.
domainMap = {
'www.yourwebsite.cn': 'cn'
},

Adjusting Language Mapping

The languageMap lists the most common Chinese language variations and maps them to a single CDN.

languageMap = {
'zh': 'cn',
'zh-HK': 'cn',
'zh-CN': 'cn',
'zh-TW': 'cn'
},

Adjusting Timezone Mapping

The gmtMap specifies the Chinese time zone.

gmtMap = { 
'-480': 'cn'
},

Adjusting the Match Logic

The default matchLogic for all defined variables requires them to all be true. Set it to 'or' if only some of the variables need to be true.

matchLogic = 'and'; // 'or'

Turning IP Location Detection On or Off

  • If locationTest is true, fetch the users IP address and return a location.
  • If locationTestForce is true, runs the location logic every time regardless of the cookie value or other match logic results.
  • Both default to true to provide optimal location detection for every user session.
 var locationTest = true; // Use location test logic
 var locationTestForce = true; // Use location test in all scenarios

Adjusting the Cookie Duration and When to Trigger a Retest

The retestTime variable is specified in milliseconds and specifies when the retest is done to determine the user's location. The default is one day.

var retestTime = 86400000; // 1 day