Although the v10 JavaScript tag has changed significantly from previous releases, you can easily upgrade from a prior version.
You can place the v10 tag anywhere on the page. Since the tag is loaded asynchronously, it does not block page rendering in any way. You can place the tag in the <head> section or anywhere within the <body> section with minimal impact on page rendering times. In addition, the tag runs in the background, so there is minimal impact on user experience after the page has loaded.
Upgrading is a 4 step process:
Before you begin, you'll need to have:
Transform Configuration Settings
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):
<!-- START OF SmartSource Data Collector TAG v10.2.0 -->
<!-- Copyright (c) 2011 Webtrends Inc. All rights reserved. -->
<script>
window.webtrendsAsyncInit = function(){
var dcs=new Webtrends.dcs().init({
dcsid:"dcs9x99xxxx9xxx9xx9xxxx9x_9x9x",
domain:"statse.webtrendslive.com",
timezone:-3
}).track();
};
As
you can see, the name value pairs in v10 are exactly the same as the properties in v9.
To transform your v9 settings, follow these steps: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;
dcsid:"dcs9x99xxxx9xxx9xx9xxxx9x_9x9x", domain:"statse.webtrendslive.com", timezone:-3, fpcdom:".foo.com", enabled:true, i18n:false, fpc:"WT_FPC", paidsearchparams:"gclid", splitvalue:"", preserve:false
window.webtrendsAsyncInit = function(){
var dcs=new Webtrends.dcs().init({
dcsid:"dcs9x99xxxx9xxx9xx9xxxx9x_9x9x",
domain:"statse.webtrendslive.com",
timezone:-3
}).track();
};
window.webtrendsAsyncInit = function(){
var dcs=new Webtrends.dcs().init({
dcsid:"dcs9x99xxxx9xxx9xx9xxxx9x_9x9x",
domain:"statse.webtrendslive.com",
timezone:-3,
fpcdom:".foo.com",
enabled:true,
i18n:false,
fpc:"WT_FPC",
paidsearchparams:"gclid",
splitvalue:"",
preserve:false
}).track();
};
Migrate Customizations
<script type="text/javascript">
_tag.dcsCustom=function(){
// extract info from to URL
_tag.DCSext.t_B02 = document.URL.split('/')[3];
_tag.DCSext.z_brand = XlateBrand(document.URL).Name;
_tag.dcsCollect();
</script>
To achieve this using the v10 tag, edit the JavaScript as follows:
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();
Loader:
To use the loader approach, add a webtrendsAsyncLoad function definition before the script block that includes webtrends.load.js:<script>
window.webtrendsAsyncLoad=function(dcs){
dcs.DCSext.t_B02 = document.URL.split('/')[3];
dcs.DCSext.z_brand = XlateBrand(document.URL).Name;
}
</script>
<script type="text/javascript" src="/scripts/webtrends.load.js"></script>
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).
<!-- START OF SmartSource Data Collector TAG --> <!-- Copyright (c) 1996-2011 Webtrends Inc. All rights reserved. --> <!-- Version: 9.4.0 --> . . . <!-- END OF SmartSource Data Collector TAG -->
<!-- START OF SmartSource Data Collector TAG v10.2.0 --> <!-- Copyright (c) 2011 Webtrends Inc. All rights reserved. --> . . . <!-- END OF SmartSource Data Collector TAG v10.2.0 -->
(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
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=...