Getting started

Installation

To use our JavaScript API, you need to place the following code between script tags, preferably in between head tags. Remember to change the value YOUR_API_KEY by the key API you have been assigned. You can find this pre-configured snippet on your Allo-Media account, in the "summary" tab of each of your campaigns.

<script>
(function(k,e,t,c,h,u,p){k['AlloAnalyticsObject']=h;k[h]=k[h]||function(){
(k[h].q=k[h].q||[]).push(arguments)},k[h].l=1*new Date();u=e.createElement(t),
p=e.getElementsByTagName(t)[0];u.async=1;u.src=c;p.parentNode.insertBefore(u,p)
})(window,document,'script','https://hermes.allo-media.net/static/js/amloader.js','am');

am('create', 'YOUR_API_KEY');

// You can launch the replacement whenever you want, as long as the am object is initialized.
am('start');
</script>

Options

When calling the create method, it is possible to specify a series of options, detailed below.

cookieVisitorExpires

This option allows you to customize the maximum cookie retention time.

LabelTypeComment
cookieVisitorExpiresintCookies' expiration delay, in seconds.
Default value: 1 year.

Example:

am('create', 'AM-votreapikey', {
cookieVisitorExpires: 15780000 // 6 mois en secondes
});

localStorage

If you wish you can use localStorage as an alternative to cookies.

LabelTypeComment
localStoragebooleanIf true, enable the use of localStorage instead of cookies.
Default value: false.

Example:

am('create', 'AM-votreapikey', {
localStorage: true
});

fallbackToCookies

If the localStorage option is set to true, it is possible to specify if you still want to use cookies if localStorage is not available on the browser used.

LabelTypeComment
fallbackToCookiesbooleanIf false, browsers that do not support localStorage will not replace phone numbers.
Default value: true.

Example:

am('create', 'AM-votreapikey', {
fallbackToCookies: true
});

ignoreAttributes

It is possible to prevent the script from replacing phone numbers present in some HTML tag attributes.

LabelTypeComment
ignoreAttributesstring[]A table containing the list of attributes you wish to ignore.
Default value: [].

Example:

am('create', 'AM-votreapikey', {
ignoreAttributes: ['data-phonenumber']
});

ignoreSelectors

It is possible to prevent the script from replacing phone numbers according to certain selectors.

This option will be ignored if the replaceSelectors option is used as well.

LabelTypeComment
ignoreSelectorsstring[]An array containing the list of selectors.
Default value: ["#comment", "svg"].

Example:

am('create', 'AM-votreapikey', {
ignoreSelectors: ['#header > a']
});

replaceSelectors

It is possible to replace telephone numbers present only in selected selectors.

LabelTypeComment
replaceSelectorsstring[]A table containing the list of selectors in which to search for phone numbers.
Default value: [].

Example:

am('create', 'AM-votreapikey', {
replaceSelectors: ['span']
});

multipages

This option allows, as much as possible, to keep the same tracking number from page to page. Setting it to false disables cookies.

LabelTypeComment
multipagesbooleanDefault value: true.

Example:

am('create', 'AM-votreapikey', {
multipages: false
});

Callback

You can define a callback function that will be executed after the replacement of the number(s).

Exemple :

function myCallback() {
// Do something after the phone number has been replaced
}

am('set', 'callback', myCallback);

Collision with the am object

The Allo-Media library creates by default an object named am in the window object. You can change the name of this object if it conflicts with an object with the same name in the global scope.

Simply change the am parameter passed as a parameter to the main snippet function, and remember to modify the calls to this object.

Example :

// Let's change it for "foo"

(function(k,e,t,c,h,u,p){k['AlloAnalyticsObject']=h;k[h]=k[h]||function(){
(k[h].q=k[h].q||[]).push(arguments)},k[h].l=1*new Date();u=e.createElement(t),
p=e.getElementsByTagName(t)[0];u.async=1;u.src=c;p.parentNode.insertBefore(u,p)
})(window,document,'script','https://hermes.allo-media.net/static/js/amloader.js','foo');

// Don't forget to change the calls
foo('create', 'YOUR_API_KEY');
foo('start');

Provide additional data

You can send additional data, usually a customer-controlled identifier, to each page viewed. This data should be sent in the following manner:

am('set', 'trackingIds', {superTracker5: 'tata'})

Be careful, the set parameter overwrites the data previously sent. To add data to the existing ones, it is generally advisable to proceed as follows:

am('set', 'trackingIds', Object.assign(am('get', 'trackingIds'), {
superTracker5: 'tata'
}));

Replace phone numbers from multiple campaigns

If you have several phone numbers on the same page, and each of these numbers is part of a different campaign, the classic operation of the script will allow you to replace only the first number found.

A solution exists. You have to execute the am('start') function several times, specifying in parameter the identifier of the campaign, as in the following example :

am('start', 'am7658');
// then
am('start', 'am9356');