You can have a look at this http://support.mobileapptracking.com/entries/22561636-How-Google-Play-Install-Referrer-Works
Basically you need to add you tracking ID to google play url. Then when app installs, collect the same from google play.
You will need to add a receiver in you app, filtering this
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>