One way to track referrals from a 301 redirect is to append a URL parameter. However, if you use a question mark (?) to do so, you will create duplicate content issues that impact your search engine rankings. To solve this issue, use a hash (#) tag instead.
In WebTrends, tracking hash tags as part of the query string requires custom changes to the page tag.
Old Tag Versions
For older tag versions (1.x.x), the following changes need to be performed on the wtinit.js and wtbase.js files.
(1) In the wtbase.js file, add and run a dcsHash() function that will parse “hash” parameter-value pairs. For each page tag call, dcsHash() is called if and only if the custom trackhashes variable is set to true (set in step 2).
(2) Add a line of code to the wtinit.js file that enables a flag needed in the tracking of “hash” parameters.
To turn off the tracking of hash parameters, you can set this.trackhashes to false.
New Tag Versions
Due to code structure changes in the most recent tag versions (8.x.x) created from WebTrends Tag Builder, there are slight differences to the way you should modify the new tags compared to the old ones. The following changes need to be performed on the inline code and webtrends.js file.
(1) In the WebTrends() function of the webtrends.js file, assign a default value of false to a custom trackhashes variable.
Note: Always set the trackhashes variable to false since this acts as a default value. If you want to enable the tracking of “hash” parameters and set this variable to true, do so in step 3 below.
(2) In the webtrends.js file, add and run a dcsHash() function that will parse the “hash” parameter-value pairs. For each page tag call, dcsHash() is called if and only if the custom trackhashes variable is set to true (set in step 3).
(3) In the inline code right before the _tag.dcsCollect(); line, set the trackhashes value to true to enable the “hash” tracking functionality.
To turn off tracking of “hash” parameters, you can set _tag.trackhashes to false.
When this has been completed, the WebTrends tag will treat the “hash” parameters as if they are regular query string parameters. You will then be able to use and report on the “hash” parameters as dimensions in custom reports.