Skip to main content

3rd Party Landing Page

This page contains an example to add the following functionality to a 3rd party landing page:

  • Prompt user to share location
  • Update scan location to user's location

The scan ID will usually be passed as a query parameter in the URL like this:

To obtain your api-key:

portal > campaign > settings > redirect



<script src="./scantrust_stc_sdk.js" type="text/javascript"></script>
<script src="./script.js" type="text/javascript"></script>


function ScanTrustConsumerSDK(apiKey) {
var apiKey = apiKey
var scanId = ""

// User accepted to share his position and a GPS location was retrieved
// The pos object contains the position coordinates.
// -> Latitude
// pos.coords.lng -> Longitude
var success = function (pos) {
fetch("<uuid>/geotag/", {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"X-ScanTrust-Consumer-Api-Key": apiKey,
body: JSON.stringify({
lat: pos.coords.latitude,
lng: pos.coords.longitude,
.then(function (response) {
if (response.ok) {
return response
} else {
throw new Error()
.then(function () {
"Scantrust Consumer SDK: Scan Location successfully updated"
.catch(function (err) {
console.error("Scantrust Consumer SDK Error: " + err)

// User didn't accept to share his position or the browser was unable to retrieve a GPS location
// Reason for failure is inside the positionError object.
// positionError.code == 1 PERMISSION_DENIED, The acquisition of the geolocation information failed because the page didn't have the permission to do it.
// positionError.code == 2 POSITION_UNAVAILABLE The acquisition of the geolocation failed because at least one internal source of position returned an internal error.
// positionError.code == 3 TIMEOUT The time allowed to acquire the geolocation, defined by positionOptions.timeout information was reached before the information was obtained.
var error = function (positionError) {
"Scantrust Consumer SDK : Can't retrieve position. Code: " +
positionError.code +
" message: " +

this.updateScanLocation = function (id) {
if (!id) {
console.error("Scantrust Consumer SDK Error: Scan ID Not provided")

scanId = id

var positionOptions = {
enableHighAccuracy: false,
timeout: 5000,

navigator.geolocation.getCurrentPosition(success, error, positionOptions)


var API_KEY = "replace-with-you-api-key"
// The scan ID will usually be passed as a query parameter in the URL. Example:
var scanId = "90ee96a4-f7ef-44fb-a3d9-181f62ae590d"

var sdk = new ScanTrustConsumerSDK(API_KEY)