By default, Acoustic Campaign tracks web page visits by the entire URL up to the query string, which typically begins with the "?" symbol. For example, www.goacoustic.com/index.html?content=januaryupdate will be returned in your web tracking Summary report as index.html. By adding a single JavaScript variable to your page code, you can begin tracking visits to pages that contain dynamic URLs.
You have a few options, depending on what data you would like to capture and pass back to your web tracking summary report, but the results will always be returned through a global JavaScript variable called ewt_pagename
, because Campaign accepts the value of ewt_pagename if it is found on your tracked page.
For example, it would be possible to add a JavaScript function to your page code that will search the URL for signs of a query string. If one is detected, it can then accept the value of ewt_pagename. If a query string is not detected in your URL only the default page name needs to be displayed. You can achieve this with a simple JavaScript function by using the below sample code:
<script type='text/javascript'>
var ewt_pagename;
function queryStringCheck() {
if (window.location.href.indexOf('?') > 0) {
ewt_pagename = ****
}
else {
return false;
}
}
queryStringCheck();
</script>
If your web page is http://www.example.com/index.html?content=januaryupdate you can use a regular expression to parse the URL and return a value of index.html?content=januaryupdate
. To do so, replace the line above in the function that contains **** with: ewt_pagename = window.location.href.match(/[^\/]+$/);
If your web page generates a dynamic title with the query string, you can pull the page title and pass that back to the Acoustic Campaign. To do so, replace the line above in the function that contains **** with: ewt_pagename = document.title;