Tracking Using Document Object Model (DOM)

For complex websites that enforce rigorous separation of logic and presentation, you can use the Document Object Model (DOM) method to implement the dcsMultiTrack function.

Implement dcsMultiTrack on a DOM element ID or other criteria such as anchor tags that lead to PDF documents. To illustrate basic implementation using DOM with dcsMultiTrack, two examples are included in the following sections. The first example illustrates activating dcsMultiTrack for a particular DOM element ID. The second example illustrates activating dcsMultiTrack for a specific DOM tag name.

Note: Using DOM methods with dcsMultiTrack is a complex implementation that requires an understanding of DOM methodology and programming skills that are beyond the scope of this document. The following examples are for illustration purposes only–do not copy and paste the code examples to your web page as they may not work as expected.

Example: Specifying DOM Element ID with dcsMultiTrack

The following example shows how to activate dcsMultiTrack for a particular DOM element ID:

<script type="text/javascript">
var x=getElementByID("page_of_interest");
x.onclick="dcsMultiTrack('DCS.dcssip', 'www.domain_name',
 'DCS.dcsuri', '/folder/page_of_interest.html',
 'WT.ti', 'Page%20of%20Interest');"
</script>
...
<a id="page_of_interest" href="http://www.somedomain.com/folder/page_of_interest.html">Page of Interest</a>

Example: Specifying DOM Tag Name with dcsMultiTrack

The following example shows how to activate dcsMultiTrack for a particular DOM tag name:

<a id="page1" href="http://www.somedomain.com/folder/page_of_interest.pdf">Page of Interest 1</a>
<script type="text/javascript">
var x=document.body.getElementsByTagName("a");
for (i=0;i<x.length;i++) {
if (x[i].href.toUpperCase().indexOf("PDF") >= 0) {
var url_split=x[i].href.match(/(\w+):\/\/([\w.]+)(\/\S*)/);
var wt_domain=url_split[2];
var wt_uri=url_split[3];
var wt_title=x[i].innerHTML
x[i].onclick=function(){
	dcsMultiTrack('dcssip', wt_domain, 'dcsuri', wt_uri, 'WT.ti', 	wt_title);
};
}
}
</script>