Developer Docs

Welcome to Authmetrik Developer Documentation. Here you will find all of the technical documentation necessary for integrating your system with AuthMetrik. You will use Javascript to send data.

Installation/Setup

Use the script to setup AuthMetrik in your system. You can place the JavaScript snippet anywhere in the HTML document, but we ask that you place the JavaScript snippet in the head to let our script load as soon as possible, to be able to send events before the visitor leaves.

<script>
var _amq = _amq || [];
var _amk = _amk ||[API KEY];
function _ams(u){
setTimeout(function(){
var d = document, f = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.type = 'text/javascript'; s.async = true; s.src = u;
f.parentNode.insertBefore(s, f);
_amq.push(["checkDevice"]);
}, 1);
}
_ams('[AM JS Link]');
</script>

Make sure to replace [API KEY] with your API key and [AM JS Link] with link our support provides to you.

Create Users

Load AM Registration Tracker

Use this script to load Authmetrik tracker on registration page.

var fieldArray = {usernameFields : [ Username, Confirm Username]}; _amq.push(["configureUsernameFields", fieldArray])

Request

Parameter

Datatype

Description

Username

String

Element Id of username field

Confirm Username

String

Element id of confirm username field

We highly recommend using email address as username.

<script>
var fieldArray = {usernameFields : [ '#email', '#confirmEmail' ]};
_amq.push(["configureUsernameFields", fieldArray])
</script>

Create new user

On successful registration, push registered user’s data to AuthMetrik.

_amq.push(["newUser", uid, properties, callback]);

Request
Response

Parameter

Datatype

Description

uid

String

Unique random identifier for the user

Properties

Object

Custom properties related to a new user

callback

function name

Callback function name to handle AuthMetrik authentication decision

{
"message":null,
"success":false,
"kdScore":0.0,
"errorCode":0,
"approvalStatus":null,
"identifier":"0f3lqASfxWKbG8gyIU/4qhEmmTo="
}

Verify Users

Load AM Verify Tracker

Use this script to load Authmetrik tracker on login page.

var fieldArray = {usernameFields : [ Username]}; _amq.push(["configureUsernameFields", fieldArray])

Request

Parameter

Datatype

Description

Username

String

Element id of username field

Verify User

On successfully receiving correct login credentials, push user’s data to AuthMetrik.

_amq.push(["returningUser", uid, properties, callback]);

Request
Response

Parameter

Datatype

Description

uid

String

Unique random identifier for the user

Properties

Object

Properties related to returning user

callback

Function Name

Callback function name to handle AuthMetrik authentication decision

{
"message":null,
"success":false,
"kdScore":0.63,
"errorCode":0,
"approvalStatus":"APPROVED",
"identifier":"0f3lqASfxWKbG8gyIU/4qhEmmTo="
}

Sample Code

registration.html
registration.js
<!DOCTYPE html>
<html class="html">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" type="image/png" href="/assets/imgs/favicon.png" />
<!-- AuthMetrik installation code -->
<script>
var _amq = _amq || [];
var _amk = _amk || 'InsertYourAPIKeyHere';
function _ams(u){
setTimeout(function(){
var d = document, f = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.type = 'text/javascript'; s.async = true; s.src = u;
f.parentNode.insertBefore(s, f);
_amq.push(["checkDevice"]);
}, 1);
}
_ams('https://cdn.authmetrik.com/am.js');
</script>
<!-- AuthMetrik installation ends -->
</head>
<body>
<form class="form_auth" id="demo_signup_form" action="/register" method="POST" autocomplete="off">
<div class="form-group">
<input placeholder="Email Address" type="text" class="form-control" id="email" name="email" value="" />
</div>
<div class="form-group">
<input placeholder="Confirm Email Address" type="text" class="form-control" id="confirmEmail" name="confirmEmail" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
<script src="//static.authmetrik.com/assets/vendor/jquery/jquery-1.12.0.min.js"></script>
<!-- Load AM Registration Tracker -->
<script>
var fieldArray = {usernameFields : [ '#email', '#confirmEmail' ]};
_amq.push(["configureUsernameFields", fieldArray])
</script>
<!-- Load AM Registration Tracker ends -->
</body>
</html>
login.html
login.js
<!DOCTYPE html>
<html class="html">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="shortcut icon" type="image/png" href="/assets/imgs/favicon.png" />
<!-- AuthMetrik installation code -->
<script>
var _amq = _amq || [];
var _amk = _amk || 'InsertYourAPIKeyHere';
function _ams(u){
setTimeout(function(){
var d = document, f = d.getElementsByTagName('script')[0],
s = d.createElement('script');
s.type = 'text/javascript'; s.async = true; s.src = u;
f.parentNode.insertBefore(s, f);
}, 1);
}
_ams('https://cdn.authmetrik.com/am.js');
</script>
<!-- AuthMetrik installation ends -->
</head>
<body>
<form class="form_auth" id="demo_signup_form" action="/register" method="POST" autocomplete="off">
<div class="form-group">
<input placeholder="Email Address" type="text" class="form-control" id="email" name="email" value="" />
</div>
<div class="form-group">
<input placeholder="Password" type="password" class="form-control" id="password" name="password" />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</form>
<script src="//static.authmetrik.com/assets/vendor/jquery/jquery-1.12.0.min.js"></script>
<!-- Load AM Login Tracker -->
<script>
var fieldArray = {usernameFields : [ '#email']};
_amq.push(["configureUsernameFields", fieldArray])
</script>
<!-- Load AM Login Tracker ends -->
</body>
</html>