This module receives and stores the INSTALL_REFERRER sent by Google Play (where exists), which can then be returned when you need it.
The module (net.pixelfactor.installreferrer-android-1.zip) is located under the dist folder. Add it to your Titanium project using your preferred method. If you are not sure how to do this, check Using Titanium Modules.
There is no need to add anything else to your tiapp.xml file, however, you must make sure that you don’t already have a receiver for the INSTALLL_REFERRER action. If your tiapp.xml already contains
<action android:name="com.android.vending.INSTALL_REFERRER" />
somewhere in it, delete its receiver.
In your application, where you need to retrieve the INSTALL_REFERRER, add the following:
var installReferrer = require('net.pixelfactor.installreferrer');
var utmSource = decodeURIComponent(installReferrer.getUtmSource());
This will return the INSTALL_REFERRER string in the following format:
utm_source=Source&utm_medium=Medium&utm_term=Term&utm_content=Content&utm_campaign=Name
or NULL if no INSTALL_REFERRER was received from Google Play.
Since the INSTALL_REFERRER string is saved with the application, it will be returned (if sent) every time you call getUtmSource() method, so if you want to track this only after the application has been launched for the first time, you will have to implement it yourself.
If you want to test it without having to upload an APK to Google Play, you can use the Referral Tester app (NOT FREE) which will simulate a market broadcast.