Example - AFS

AFS Integration Guide

Product
AFS
AFS_Version
7.7
Category
Reference Guide

Hereafter is shown how the tracking code can be installed.

<a id="example-1" href="1.html" title="Access to page 1">Page 1</a>
<a id="example-2" href="2.html" title="Access to page 2">
<img src="page2.png"/>
</a>
<a id="example-3" href="3.html" title="Access to page 3">Page 3</a>
<a id="example-4" href="4.html">Page 4</a>

<script type="text/javascript">
// Click WS will receive: target=1.html label=Page 1
AFSWidget.sdk.click.track(document.getElementById('example-1'));

// Click WS will receive: target=2.html label=Access to page 2
AFSWidget.sdk.click.track(document.getElementById('example-2'));

// Click WS will receive: target=3.html label=Page #3
AFSWidget.sdk.click.track(document.getElementById('example-3'), {
  label: 'Page #3'
});

// Click WS will receive: target=4.html
AFSWidget.sdk.click.track(document.getElementById('example-4'));
</script>

Do not call this method in a click handler! The method takes care itself of the event listening.

From a JavaScript code, a new status can be pushed to the web service like this:

function foobar()
{
// …

AFSWidget.sdk.click.push({
  target: '1.html'
  label: 'Page #1'
});

// ...
}