TapResearch JavaScript Integration Guide

Getting Started

Create an app and grab your API Token.

Embed the JavaScript loader

Add within your head tag. The TapResearch JS SDK will be asynchronously loaded without blocking your page load.

<script type="text/javascript">
!!function(e,t){window.TapResearch=t,t.loadLibrary=function(e){var o=document.createElement("script"),a=document.getElementsByTagName("head")[0];o.src=t.host+"/assets/sdk.js"+(e?"?ver="+e:""),o.async=!0,a.appendChild(o),t.loadTimeout=setTimeout(function(){t.handleTimeout()},t.config.load_timeout||2e3)},t.init=function(e){t.config=e,t.host="https://www.tapresearch.com",t.loadLibrary()}}(document,window.TapResearch||[]);
</script>

Configure the SDK

<script type="text/javascript">
  TapResearch.init({
    api_token: "YOUR_API_TOKEN",
    user_identifier: "USER_ID",
    has_survey_callback: function(data) {
      // Add offer link (data.offer_url) to your page
    },
    no_survey_callback: function() {
      // Optional: suppress any loading message
    }
  });
</script>

user_identifier

user_identifier should be a persistent unique identifier (preferably hashed) for this user. This allows us to more accurately track users between sessions, to avoid asking the same profiling questions repeatedly. user_identifier will be used in scenarios where multiple users are seen on the same device.

has_survey_callback

This function is called when the JS SDK loads and has determined there is a survey available for this user. The function has one argument - an object like:

{
  has_offer: true
  message_hash: {min: "50", max: "200", currency: "coins"}
  offer_url: "https://www.tapresearch.com/router/offers/99678b60f874295ac4ac44c82bbd9dc3c0863f70/pre_entry?uid=38c346cbe20774e7b433e23815bff76c"
  sdk_version: 1
}

Where message_hash provides minimum and maximum reward amounts available given current survey inventory, and offer_url is the entry URL to the TapResearch router.

no_survey_callback

This function is called in two scenarios:

  1. The JS SDK loads and has determined there is no survey available for this user.
  2. The JS SDK is unable to load in a reasonable amount of time. The default is 2000ms. You can pass a different value (in ms) to the init() function as load_timeout.

Build the survey entry link

The API payload includes an offer_url property like:

https://www.tapresearch.com/router/offers/99678b60f874295ac4ac44c82bbd9dc3c0863f70/pre_entry?uid=38c346cbe20774e7b433e23815bff76c

Optional: Append a tid parameter with a unique transaction ID for this session. For example:

https://www.tapresearch.com/router/offers/99678b60f874295ac4ac44c82bbd9dc3c0863f70/pre_entry?uid=38c346cbe20774e7b433e23815bff76c&tid=asdf1234

This is useful to track performance if you have multiple entry points with your app. We will send this transaction ID back in the reward postback.

Reward postback

Within your dashboard, configure a postback URL for your app.

Upon survey completion, we will call this post back with the user's transaction ID, user ID and payout amount. For more information, please visit our API docs.

Test Devices

Before you are ready to go live, it is important that your reward callback is working properly. Navigate to your dashboard and click the Add Devices button. Add a device name and your advertiser identifier. Now, when you enter our survey flow through your app, you will be able to complete a test survey and receive a test reward when you re-open your app.

Example app

Check out our example web app at: https://github.com/TapResearch/js-sdk-example

Contact

Please send all questions, concerns, or bug reports to developers@tapresearch.com.

FAQ

Do we have to pay to use the TapResearchSDK?

No. Our SDK is completely free of charge. In fact, we pay you every time a user completes a survey.

What kind of analytics do I have access to?

Our dashboard will show metrics for sessions, impressions, revenue, and much more. We are constantly enhancing our analytics so we can better serve your needs.

What is your fill rate?

We have thousands of surveys and add a few hundred more every day. Most users will have the opportunity to complete at least one survey on a daily basis.

I'm ready to go live! What are the next steps?

Let us know! We need to update the status of your app so your users can see real surveys. Note, test devices will only be able to see a test survey.