Get started
Our Android SDK is shipped as an Android library (AAR) which you need to add as a dependency to your Gradle file.
How to include it
Section titled How to include itFor distribution of our API we use Maven Central Repository which is supported by the Android build system by default. To add our SDK (or library), add the following line to your application’s dependency list.
implementation "com.contentsquare.android:library:4.26.0"
implementation("com.contentsquare.android:library:4.26.0")
To enable Jetpack Compose support, it is necessary to add another dependency to your Gradle build file.
implementation "com.contentsquare.android:compose:4.26.0"
implementation("com.contentsquare.android:compose:4.26.0")
Start the SDK
Section titled Start the SDKYou do not need to do anything to start the SDK. Now that the SDK is a dependency of your app, it will autostart itself when your application starts.
Disabling Automatic SDK Initialization
Section titled Disabling Automatic SDK InitializationSet the com.contentsquare.android.autostart
flag to false in your AndroidManifest.xml
file.
<application> ... <meta-data android:name="com.contentsquare.android.autostart" android:value="false" /> ...</application>
Then, you can start the Contentsquare SDK by calling the start()
method of the Contentsquare class.
Contentsquare.start(context)
This initialize function is called automatically on app startup if the com.contentsquare.android.autostart
flag is not listed in the AndroidManifest.
This function should be called before the first activity is created. Call this function in the onCreate()
method of a custom Application subclass:
import android.app.Applicationimport com.contentsquare.android.Contentsquare
class MyApplication : Application() { override fun onCreate() { super.onCreate()
// Start Contentsquare SDK Contentsquare.start(this) }}
Validate SDK integration
Section titled Validate SDK integrationStart your application, you should see the SDK print a log like this one:
I/CSLIB: Contentsquare SDK 4.26.0 starting in app: your.application.package
If the SDK does not seem to work, it might mean that your app’s package name is not tied to any Contentsquare project. In that case, you will have to communicate all variants of your app’s identifier to your Contentsquare contact to be added as a project.
Now that the SDK runs in your app, you will want to implement calls to our SDK to track screenviews, transactions, and more. Keep following along this guide to know how.
Sample App
Section titled Sample AppFor best implementation practices of our library, explore the Contentsquare for Android sample app.
Use Tealium
Section titled Use TealiumOur partner Tealium has developed a remote command module to integrate with the Contentsquare SDK. This solution leverages the convenience of iQ Tag Management to configure a native Contentsquare implementation without having to add Contentsquare-specific code to your app.
Follow instructions on Tealium’s documentation: Remote Command for Contentsquare.