Home - ProspectEye/ApsisLead-Tracker-API GitHub Wiki

Apsis Lead Tracker API

You need an active Apsis Lead account to be able to use the API

This is a documentation for Apsis Lead Tracker API and it's functions. This documentation is intended for web-developers and the main purpose is to explain how our tracker can be called from your site through javascript to be able to track dynamic webpages.

Add the script to your footer

First of all, you need to include our tracker script on your site in order to load our API.

<script type="text/javascript">
    var psSite = "YOUR-ID";
    (function() {
        var AL = document.createElement('script'); AL.type = 'text/javascript'; AL.async = true;
        AL.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + "tr.apsislead.com/al_v2.js";
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(AL, s)
    })();
</script>
<noscript><img src="http://tr.apsislead.com/?id=YOUR-ID" style="border:0;display:none;"></noscript>

Explanation

var psSite = "YOUR_SITE_CODE"; var psDynamicSite = true;

Make sure you replace YOUR_SITE_CODE in psSite with your own site code or your pageviews won't be tracked. If you have a dynamically generated webpage and you want to trigger pageviews yourself, just set psDynamicSite = true and we won't trigger a pageview on DOMReady/pageload.

Automatic form tracking (no longer supported)

Apsis Lead can automatically track all emails written in any form on your website. To enable this contact your salesperson @ Apsis Lead.

In order to get a better overview of what forms your visitors use you can assign each form a name that will show up in Apsis Lead. For this to work you need to make sure all <input> fields where the user types in their email address is of the type email. In most cases input fields are of the type text, and you need to make sure you changed this to email on all intended fields for us to be able to track the form correctly.

To give the form at name, just add the attribute data-formname, or for example data-formname="pricelist".

A correct input field for the users email could look like this.

<input type="email" name="email" data-formname="login"/>

You can keep whatever other attributes you need in the tag - class, other data-attributes and whatever else you need. The most important is that the type is email and that the data-formname attribute is set.

Dynamic tracking API

Function

ApsisLead.callTracker(jsonSettings, nAppendType, bShouldAppend, callback)

Parameters

Param: jsonSettings = {}

Optional settings:

{
  'url': 'Page Url',        //example http://www.apsislead.com/index.php
  'pagename': 'Page Title', //example ApsisLead Mainpage
  'referer': 'Referer Url', //example http://www.google.se/q=apsislead%20ab
  'cookie': true|false,     //example Should the tracker set a cookie or not
  'pedata': {
    'type': 'F',
    'email': '[email protected]',
    'form_name': 'Newsletter'
  }
}

Param: nAppendType = ApsisLead.kPEAppendScript|ApsisLead.kPEAppendFrame

ApsisLead.kPEAppendScript - This alternative appends the tracker as a script-call

ApsisLead.kPEAppendFrame - This alternative appends the tracker as a 1x1-pixel IFrame

Param: bShouldAppend = true|false

true - The tracker is appended and called automatically

false - The tracker is returned as a script-object or a iframe-object for you to append by yourself

Param: callback = function, Called when tracker has recieved data

PEData

PEData is optional and can be sent with the tracker-call. PEData is user-based information that is picked up from forms on your website.

Types:

  • 'F' Forms

Example 1: You have a form that lets your users subscribe to a newsletter. In order to send this information to the tracker you extend the jsonSettings with the value pedata

{
  url: 'Page Url',
  ...
  pedata: {
    type: 'F',
    email: '[email protected]',
    form_name: 'Newsletter'
  }
}

type and form_name are standard fields and you can assign almost any key-pair of string-data. In this example we add the data `email: '[email protected]'

Example 2: You have a login on your webpage and want to send this information to be able to exclude login-customers

{
  url: 'Page Url',
  ...
  pedata: {
    type: 'F',
    username: '[email protected]',
    form_name: 'Login'
  }
}

API Call Examples

Standard:

ApsisLead.callTracker({}, ApsisLead.kPEAppendScript, true);

Custom:

ApsisLead.callTracker({
  'url': 'http://www.apsislead.com/index.php',
  'pagename': 'ApsisLead Mainpage'
}, ApsisLead.kPEAppendScript, true);

Custom (with formdata):

ApsisLead.callTracker({
  'url': 'http://www.apsislead.com/index.php',
  'pagename': 'ApsisLead Mainpage',
  'pedata': {
    'type': 'F',
    'email': '[email protected]',
    'form_name': 'Newsletter'
  }
}, ApsisLead.kPEAppendScript, true);

Custom (Append by yourself):

var tracker = ApsisLead.callTracker({
  'url': 'http://www.apsislead.com/index.php',
  'pagename': 'ApsisLead Mainpage',
  'pedata': {
    'type': 'F',
    'email': '[email protected]',
    'form_name': 'Newsletter'
  }
}, ApsisLead.kPEAppendScript, false);

document.getElementsByTagName("head")[0].appendChild(tracker);

Further examples

We have written two more extensive examples on how to track forms and single page applications. See WORKING WITH THE ApsisLead DYNAMIC TRACKING API for the examples.

⚠️ **GitHub.com Fallback** ⚠️