1.0.2 • Published 3 years ago

@tapfiliate/tapfiliate-js v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

Tapfiliate npm module

This is a simple wrapper for the Tapfiliate JavaScript integration library to help with implementation in modern frontend applications.

Table of content

Installation

With npm:

npm install @tapfiliate/tapfiliate-js

With yarn:

yarn add @tapfiliate/tapfiliate-js

Import and initialize your tracking using the init function. Get your account id from your account settings.

import Tap from "@tapfiliate/tapfiliate-js";

Tap.init(accountId);

The init function will add the Tapfiliate script to your webiste's head tag. This is needed for you to be able to use the rest of the Tap functions.

Test your integration

To test your Tapfiliate setup you can simply add ?tap_test=true at the end of your url to open the tapfiliate tester. Read more about testing your integration here.

API

This npm module mirrors the Tapfiliate JavaScript integration library and all functions from the Javascript Docs can be used with this wrapper with the only difference that the first parameter is now the function name.

e.g. instead of: tap('conversion', external id, amount, options, commission type, callback); You can now use: Tap.conversion(external id, amount, options, commission type, callback)

Init

To make the initialization easier we added the init function. Use Tap.init to initialize Tapfiliate. The function loads the tapfiliate javascript to your site's head tag and then calls the two functions Create & Detect to initialize the Tap object.

Tap.init(accountId, createOptions, createCallback, detectOptions, detectCallback);

Arguments

NameValue
accountIdString. Your account id.
createOptionsObject. Currently no options. This argument only functions as a stub for possible future options.
createCallbackFunction. Callback, to be called after the tracking code has been initialized. In case a visitor id exists for the current visitor, tap.vids will be populated at this point.
detectOptionsObject. See table 'detectOptions' below
detectCallbackFunction. Callback, to be called after a click is tracked. Important: This callback will only fire upon successfully tracked clicks. We are aware this is against convention. However, we're keeping it in place in order to not cause any BC breaks. The method will be deprecated in the future in favour of a new method, that uses conventional callback behaviour. For now you can pass always_callback: true in the options to make the callback always fire. In this case the callback will look as follows: function(error, result) {}
DetectOptions
OptionsOption values
cookie_domainstring. Explicitly define the domain to place the cookie on. Can be used when users land on subdomain A and later convert on subdomain B.
referral_codeString Use this to explicitly pass a specific referral code for this click.
referral_code_paramString. Use an alternative query parameter for the referral code, instead of ref. For example if you would like your links to look like: https://.../?via=, pass via
always_callbackBoolean Set to true to also make your callback fire on failed tracking attempts. More info