dependencies{//only required if you do not have this reference
compile 'com.tealium:library:5.5.1'
compile 'com.tealium:installreferrer:1.0'//only required if you do not already have this reference and require lifecycle tracking
compile 'com.tealium:lifecycle:1.1.1'}

In the same block where you instantiate the Tealium library (after instantiating Tealium), add the following calls:

// import the Tealium InstallReferrer module in the import section
importcom.tealium.installreferrer.InstallReferrerReceiver;// substitute the example instance name here with the same instance name you used when initializing the Tealium library
privatestaticfinal String TEALIUM_INSTANCENAME ="INSTANCE_NAME";// call this to store the referrer as Persistent data - recommended
InstallReferrerReceiver.setReferrerPersistent(TEALIUM_INSTANCENAME);// call this to store the referrer as Volatile data (reset at app restart/terminate) - not recommended in most cases
InstallReferrerReceiver.setReferrerVolatile(TEALIUM_INSTANCENAME);

Include in your app’s “libs” directory, and add the following to your project module’s build.gradle:

dependencies {// only required if you do not already have this reference
compile(name:'tealium-5.5.1', ext:'aar')
compile(name:'tealium.installreferrer-5.2.0', ext:'aar')// only required if you do not already have this reference and require lifecycle tracking
compile(name:'tealium.lifecycle-1.1.1', ext:'aar')}

Sample Value

You can expect to receive the following URL-formatted data in the INSTALL_REFERRER variable, assuming that your incoming URL contained all the specified campaign information.

Additional Considerations

BroadcastReceiverThis module implements a BroadcastReceiver, specifically for the INSTALL_REFERRER broadcast. This broadcast is only sent once on first launch of the app, and the Android OS will only call the first BroadcastReceiver for this particular broadcast, even if you define more than one BroadcastReceiver. Thus, if you have other 3rd party SDKs that handle the INSTALL_REFERRER, you will need to implement a “proxy” BroadcastReceiver that calls the onReceive method of each individual receiver for the INSTALL_REFERRER broadcast.

Delete the Stored Referrer
To delete the stored install referrer string, you can call the standard methods provided by the Tealium library to remove variables from persistent or volatile storage. The key name for the variable is exposed by the InstallReferrerReceiver class. Here’s an example to remove the stored install referrer from both persistent and volatile data. This code will have no effect and will not throw an error, if the variable doesn’t already exist.