Skip to content

ajanauskas/web_sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

This is the guide to the Javascript SDK of Adjust™ for web apps. You can read more about Adjust™ at adjust.com.

Table of contents

Example apps

You can check how SDK can be used in the web app by checking example app in this repository.

Basic integration

This SDK can be used to track installs, sessions and events. Simply add the Adjust JS SDK to your web app.

Recommendations

There are two ways to differentiate users coming from native apps to users coming from web apps if you are not running ad campaigns for your web apps:

  • Create new app(s) in your Adjust dashboard for your web app, pick one of the supported platforms during the creation and use this app token in the Adjust SDK to initialise it. As with your native apps, organic traffic from your app will then be labelled under the Organic tracker in your Adjust dashboard.
  • Use one of your pre-existing app and hardcode a pre-installed tracker token in the Adjust SDK. All traffic from your app will then be labelled under the hardcoded tracker in your Adjust dashboard.

Basic setup

There are a few things to keep in mind while implementing the JS SDK:

  • As the SDK will not be able to read the platform, it is necessary that you either pass dynamically or hardcode it in the os_name parameter.
  • If your app isn't able to access or pass advertising IDs such as gps_adid or idfa or win_adid into their respective parameters, it is recommended that you pass a similarly built UUID for iOS and Android and a similar device ID to win_adid for Windows. These IDs would need to be generated by your app.

With this in mind, initialisation of Adjust JS SDK would look like this inside your web app:

var _adjust = new Adjust({
  app_token: 'YourAppToken',
  environment: 'production', // or 'sandbox' in case you are testing SDK locally with your web app
  os_name: 'android',
  device_ids: {
    gps_adid: '5056e23a-dc1d-418f-b5a2-4ab3e75daab2' // each web app user needs to have unique identifier
  }
});

_adjust.trackSession(function (result) {
    console.log(result);
  }, function (errorMsg, error) {
    console.log(errorMsg, error);
  }
);

Additional features

Once you integrate the Adjust JS SDK into your web app, you can take advantage of the following features.

Event tracking

You can use adjust to track events. Lets say you want to track every tap on a particular button. You would create a new event token in your dashboard, which has an associated event token - looking something like abc123. In order to track this event from your web app, you should do following:

var _eventConfig = {
  event_token: 'EventToken'
};

_adjust.trackEvent(_eventConfig, function (result) {
  successCb(result, 'event');
}, function (errorMsg, error) {
  errorCb(errorMsg, error, 'event');
});

Revenue tracking

You can attach revenue to event being tracked with Adjust JS SDK in case you would like to track some purchase that happened inside your web app. In order to that, you need to attach revenue and currency parameters when tracking event:

var _eventConfig = {
  event_token: 'EventToken',
  revenue: 10,
  currency: 'EUR'
};

_adjust.trackEvent(_eventConfig, function (result) {
  console.log(result);
}, function (errorMsg, error) {
  console.log(errorMsg, error);
});

When you set a currency token, adjust will automatically convert the incoming revenues into a reporting revenue of your choice. Read more about currency conversion here.

You can read more about revenue and event tracking in the event tracking guide.

Callback parameters

You can register a callback URL for your events in your dashboard. We will send a GET request to that URL whenever the event is tracked. You can add callback parameters to that event by adding callback_params parameter to the map object passed to trackEvent method. We will then append these parameters to your callback URL.

For example, suppose you have registered the URL http://www.mydomain.com/callback then track an event like this:

var _eventConfig = {
  event_token: 'EventToken',
  callback_params: [{
    key: 'key',
    value: 'value'
  }, {
    key: 'foo',
    value: 'bar'
  }],
};

_adjust.trackEvent(_eventConfig, function (result) {
  console.log(result);
}, function (errorMsg, error) {
  console.log(errorMsg, error);
});

In that case we would track the event and send a request to:

http://www.mydomain.com/callback?key=value&foo=bar

It should be mentioned that we support a variety of placeholders like {gps_adid} that can be used as parameter values. In the resulting callback this placeholder would be replaced with the ID for Advertisers of the current device. Also note that we don't store any of your custom parameters, but only append them to your callbacks, thus without a callback they will not be saved nor sent to you.

You can read more about using URL callbacks, including a full list of available values, in our callbacks guide.

Partner parameters

You can also add parameters to be transmitted to network partners, which have been activated in your Adjust dashboard.

This works similarly to the callback parameters mentioned above, but can be added by adding partner_params parameter to the map object passed to trackEvent method.

var _eventConfig = {
  event_token: 'EventToken',
  partner_params: [{
    key: 'key',
    value: 'value'
  }, {
    key: 'foo',
    value: 'bar'
  }],
};

_adjust.trackEvent(_eventConfig, function (result) {
  console.log(result);
}, function (errorMsg, error) {
  console.log(errorMsg, error);
});

You can read more about special partners and these integrations in our guide to special partners.

License

The Adjust SDK is licensed under the MIT License.

Copyright (c) 2018 Adjust GmbH, http://www.adjust.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 64.9%
  • CSS 20.7%
  • HTML 14.4%