Integrating Ads

    Integrating Ads


    Article summary

    When an ad passes through multiple media channels, you can continuously track the ad by adding query parameters to the deep link or web link URL.The example below assumes a deep link like: https://xxxx/yyyy?ak={ACCESS_KEY}&ck={CAMPAIGN_KEY}&utm_source={SOURCE}&utm_medium={MEDIUM}&utm_campaign={CAMPAIGN}&utm_content={CONTENT}

    Deep Link AndroidManifest.xml Configuration

    <activity android:name=".DeepLinkActivity">
        <intent-filter android:autoVerify="true">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data
                android:scheme="https"
                android:host="xxxx"
                android:path="/yyyy" />
        </intent-filter>
    </activity>

    Adding Query Parameters to the ShopLive SDK

    class DeepLinkHandlerActivity : AppCompatActivity() {
        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            val uri = intent?.data
            uri?.let {
                for (paramName in it.queryParameterNames) {
                    val paramValue = it.getQueryParameter(paramName) ?: continue
                    // Add query parameter for advertising {key, value}
                    ShopLive.addParameter(paramName, paramValue)
                }
                val intent = Intent(this, MainActivity::class.java)
                startActivity(intent)
            } ?: run {
                Log.e("DeepLink", "URI is null")
            }
            finish()
        }
    }