Optional Module: Install Referrer

Optional Module: Install Referrer

by ‎03-22-2018 09:03 AM - edited ‎03-22-2018 09:03 AM (233 Views)

This is a separate, optional plugin that provides a Cordova wrapper for the native Android Install Referrer module.

Installation

This feature is available as a separate npm package: tealium-cordova-installreferrer. To install:

  1. Navigate to your cordova app's directory in a terminal window, and enter cordova plugin add tealium-cordova-installreferrer.
  2. In the JavaScript file where you instantiate the main Tealium plugin, after calling tealium.init, add the following code:
function tealiumInit(accountName, profileName, environmentName, instanceName){
    var ir;
        tealium.init({...});
                 // check if installreferrer is installed and available
        ir = window.tealiumInstallReferrer;
        if (ir) {
        	  // init install referrer and store any received values as persistent data
            ir.setPersistent(instanceName);
            // Optionally, set as volatile data instead. Volatile data is cleared after the app is closed. Persistent data is therefore recommended
            // ir.setVolatile(instanceName);
        }
}

Testing

Once the installreferrer plugin has been installed, you can test that it's working by manually triggering a system broadcast. Substitute com.tealium.sample with the RDNS bundle identifier for your app (unless testing with the Tealium sample app).

> adb shell
> am broadcast -a com.android.vending.INSTALL_REFERRER -n "com.tealium.sample/com.tealium.installreferrer.InstallReferrerReceiver" --es "referrer" "utm_source=mysource&utm_medium=mymedium&utm_term=myterm&utm_content=46b25e284dc36d5a7ef8f0e6b393febe3fcc8327&utm_campaign=mycampname"

Removal

To remove the Install Referrer plugin, run cordova plugin rm tealium-cordova-installreferrer.

To delete the Install Referrer data from persistent storage, call tealium.removePersistent("install_referrer", <your tealium instance name>);