--- title: "Upgrading your Webtrends JavaScript Tag from V9 to V10" slug: "upgrading-your-webtrends-javascript-tag-from-v9-to-v10" updated: 2020-05-06T15:55:15Z published: 2020-05-06T15:55:16Z canonical: "onpremises.webtrends.help/upgrading-your-webtrends-javascript-tag-from-v9-to-v10" --- > ## Documentation Index > Fetch the complete documentation index at: https://onpremises.webtrends.help/llms.txt > Use this file to discover all available pages before exploring further. # Upgrading your Webtrends JavaScript Tag from V9 to V10 Although the v10 JavaScript tag has changed significantly from previous releases, you can easily upgrade from a prior version. We recommend placing the tag in the `<head>` section. Since the tag is loaded asynchronously, it does not block page rendering in any way. Upgrading is a 4 step process: 1. Transform Configuration Settings 2. Migrate Customizations 3. Change HTML Markup 4. Test Before you begin, you'll need to have: - Complete copies of a v9 and v10 tag (ideally, the two `.zip` files from Tag Builder). - Ability to edit HTML and JavaScript - Access to a web server, so you can test pages ## Transform Configuration Settings For v10, the configuration settings are separated from the tag logic. In v9, configuration settings are changed by editing the user modifiable properties of the WebTrends object constructor (webtrends.js): ``` function WebTrends(){ var that=this; // begin: user modifiable this.dcsid="dcs9x99xxxx9xxx9xx9xxxx9x_9x9x"; this.domain="statse.webtrendslive.com"; this.timezone=-3; this.fpcdom=".foo.com"; this.enabled=true; this.i18n=false; this.fpc="WT_FPC"; this.paidsearchparams="gclid"; this.splitvalue=""; this.preserve=false; // end: user modifiable . . . } ``` In v10, configuration settings are changed by editing the parameter that is passed to the init() method of the Webtrends object. This parameter is a JSON object comprised of name/value pairs which correspond to configuration settings. The init() method is called as part of the instantiation of the Webtrends object (`webtrends.html`): ``` ``` To achieve this using the v10 tag, edit the JavaScript as follows: 1. Rename references from "_tag." to "dcs." 2. Incorporate custom variables using the inline HTML approach or the loader approach. - Inline HTML: ``` window.webtrendsAsyncInit = function(){ var dcs=new Webtrends.dcs().init({ dcsid:"dcs9x99xxxx9xxx9xx9xxxx9x_9x9x", domain:"statse.webtrendslive.com", timezone:-3 }); // extract info from to URL dcs.DCSext.t_B02 = document.URL.split('/')[3]; dcs.DCSext.z_brand = XlateBrand(document.URL).Name; dcs.track(); ``` 1. Separate the dcs.track() method call and insert the custom variable assignments in between the dcs.init() and the dcs.track() method calls. 2. Continuing the example: - Loader: To use the loader approach, add a `webtrendsAsyncLoad` function definition before the script block that includes `webtrends.load.js`: ``` ``` ## Change HTML Markup You replace the v9 markup with the v10 markup. Examples of the markup can be found in the `webtrends.html` file which is delivered in a `.zip` file by Webtrends Tag Builder (https://tagbuilder.webtrends.com). 1. Delete the v9 markup ``` . . . ``` 2. Add the v10 markup ``` . . . ``` 3. The v10 markup contains an anonymous function that loads the `webtrends.js` file by creating a script tag dynamically. This function references the external JavaScript file `webtrends.js`. Make sure that the reference agrees with the actual location on your web server. For example, if you put your JavaScript files in the "/scripts" folder, then the code should look like this: ``` (function(){ var s=document.createElement("script"); s.async=true; s.src="/scripts/webtrends.js"; var s2=document.getElementsByTagName("script")[0]; s2.parentNode.insertBefore(s,s2); }()); ``` Note If you are using the minified version of the tag, the name of the file is webtrends.min.js ## Test Load a test page containing your HTML markup into a browser. Using an HTTP traffic sniffing tool such as Fiddler, you should see something similar to the following: ``` GET 200 text/html http://mysite/webtrends.html GET 200 application/x-javascript http://mysite/webtrends.js GET 200 application/x-javascript http://statse.webtrendslive.com/dcs.../wtid.js?callback=Webtrends.dcss.dcs9x99xxxx9xxxxxxx9xxxx9x_9x9x.dcsGetIdCallback GET 303 Redirect to http://statse.webtrendslive.com/dcs.../dcs.gif?dcsredirect=126&dcstlh=0&dcstlv=0&dcsdat=1324085229740&dcssip=... http://statse.webtrendslive.com/dcs.../dcs.gif?&dcsdat=1324085229740&dcssip=... GET 200 image/gif http://statse.webtrendslive.com/dcs.../dcs.gif?dcstlh=0&dcstlv=0&dcsdat=1324085229740&dcssip=... ```