Streaming live at 10am (PST)

Adding a tracking code to a button

#1

Hi,

We want to add some javascript to track users who click on the ‘submit’ button of our contact form, but I don’t know how to apply the code supplied by the tracking company to the submit button, can any one help please?

Instructions:

1- Please ensure the below function is used in conjunction with the original tracking code that was generated, directly below:

<script type=“text/javascript” src=“https://secure.leadforensics.com/js/00000.js"></script>
<noscript><img src=“https://secure.leadforensics.com/00000.png” alt=”" style=“display:none;” /></noscript>

2 - Below is the function code. This should be placed in the section of the website

<script type=“text/javascript”>
function track_load (docloc, doctit) {
var trk_sw = escape(screen.width).substring(0, 6);
var trk_sh = escape(screen.height).substring(0, 6);
var trk_ref = escape(document.referrer).substring(0, 1100);
var trk_tit = escape(doctit).substring(0, 200);
trk_tit = trk_tit.replace(/%u00a0/g, ‘’);
trk_tit = trk_tit.replace(/%u2122/g, ‘’);
trk_tit = trk_tit.replace(/%u[0-9][0-9][0-9][0-9]/g, ‘’);
var trk_loc = escape(docloc).substring(0, 200);
var trk_agn = escape(navigator.appName).substring(0, 100);
var trk_lng = window.navigator.userLanguage || window.navigator.language;
var trk_agv = escape(navigator.userAgent + ‘.lfcd’ + screen.colorDepth + ‘.lflng’ + trk_lng).substring(0, 1000);
var trk_dom = escape(document.domain).substring(0, 200);
var trk_user = ‘00000’;
var trk_cookie = ‘’;
var trk_guid = ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx’.replace(/[xy]/g, function© {
var r = Math.random()*16|0, v = c == ‘x’ ? r : (r&0x3|0x8);
return v.toString(16);
});
var trk_img = ‘https://secure.leadforensics.com/Track/Capture.aspx’;
var trk_link = trk_img + ‘?trk_user=’ + trk_user + ‘&trk_sw=’ + trk_sw + ‘&trk_sh=’ + trk_sh + ‘&trk_ref=’ + trk_ref + ‘&trk_tit=’ + trk_tit + ‘&trk_loc=’ + trk_loc + ‘&trk_agn=’ + trk_agn + ‘&trk_agv=’ + trk_agv + ‘&trk_dom=’ + trk_dom + ‘&trk_guid=’ + trk_guid + ‘&trk_cookie=NA’;
var preload = new Image();
preload.src = trk_link;
}
</script>

3 - Next and most importantly, the implementation of the function. Some of our clients add this OnClick code using a <href> however, you may want to add it using alternative coding methods. The function below will need to be added to all ‘buttons’ on the site that change content but do not report a change of page journey.

0 Likes