Skip to main content
All CollectionsSwaarm MMPMMP: Developer DocumentationSDK
Swaarm JS SDK: Step by Step Implementation guide
Swaarm JS SDK: Step by Step Implementation guide

An easy way to setup direct linking with Swaarm SDK

Updated over a week ago

The SwaarmJS SDK allows you to track, attribute and monitor user activity on your Web App or on any Web property without the need for redirection links or third-party cookies

You can find comprehensive instructions on how to configure web offers in the Swaarm documentation. The provided steps below will guide you through the process of implementing the necessary JavaScript code on your web app / webiste to effectively utilize direct linking.

SwaarmJS

The SwaarmJS SDK is open source and can be found on Github with more developer-targeted information.

Installing

The first step is to install SwaarmJS.

All you need to do is add the dist/swaarm.min.js in your html page, use one of our CDNs and you are ready to go. You can find an example for the same below:

https://cdn.jsdelivr.net/gh/swaarm/swaarmjs@master/dist/swaarm.min.js

Alternatively you can fetch it directly from npm: https://www.npmjs.com/package/@swaarm/swaarmjs

Getting Started

Before using the SDK you need to configure it in the following way:

Swaarm.initialize({
"trackingUrl": "http://track.yourdomain.swaarm-app.com", //This is the base url of your Swaarm tracking domain,
"webToken": "978935fe-52ce-43f4-b7fc-692bfd964f8e", //any valid SDK token for your store-app
})

You can also enable the debug mode when developing the integration to ensure that the right actions are taken:

Swaarm.initialize({
"trackingUrl": "http://track.yourdomain.swaarm-app.com", //This is the base url of your Swaarm tracking domain,
"webToken": "978935fe-52ce-43f4-b7fc-692bfd964f8e" //any valid SDK token for your store-app
"debug": true
})

Conversion & Event Tracking

The Swaarm JS SDK can also help you with tracking conversions and events as well as performing attribution on the web.

Landing Pages

To register the user for attribution on landing pages you need to run the following code:

Swaarm.land();

Attribution

After the user viewed your landing page, they might continue exploring other parts of your website. Once the user has performed an action that you want to mark as a conversion event in Swaarm you will need to run the following code:

Swaarm.attribute();

Sending Custom Events

As the user continues to explore your platform you can register their actions in Swaarm. Say for example the user subscribed to your newsletter:

Swaarm.event('newsletter-subscription')

Monetary events can also be tracked, here is one example of a sale action:

Swaarm.event('sale', {'saleAmount': 53.2})

If you are using custom currencies, that is supported as well. Here is one transaction made with 20 in-game coins that are valued at 50 USD

Swaarm.event('sale',{'saleAmount': 50,'originalSaleAmount': 20, 'originalSaleAmountCurrency': 'coins'})

User identifier

If you are also using an S2S integration together with the Web SDK or if you would like to cross check users from your internal database with users from Swaarm, you will need the Swaarm user identifier.

To fetch it, you can run the following code:

Swaarm.identifier()

Parameters

When using self-attributing networks like Google, Facebook or Tiktok it can be useful to fill the following parameters:

  • utm_campaign - the id of the campaign inside the SAN

  • utm_adset - the id of the ad set (ad group) inside the SAN

  • utm_ad - the id of the ad inside the SAN

  • utm_term - for search campaigns, the search term that led the user to your app

  • utm_source - the medium/source/placement of the ad

Examples

You can play around with our example app to better understand how web integrations should be created. You can find the example on this page.

Did this answer your question?