Get started

A newer version of this documentation is available. Switch to the latest version docs.

Our Android SDK is shipped as an Android library (AAR) which you need to add as a dependency to your Gradle file.

For 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.

build.gradle
implementation "com.contentsquare.android:library:4.28.0"

To enable Jetpack Compose support, it is necessary to add another dependency to your Gradle build file.

build.gradle
implementation "com.contentsquare.android:compose:4.28.0"

You 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 Initialization

Set the com.contentsquare.android.autostart flag to false in your AndroidManifest.xml file.

AndroidManifest.xml
<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.Application
import com.contentsquare.android.Contentsquare
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Start Contentsquare SDK
Contentsquare.start(this)
}
}

Start your application, you should see the SDK print a log like this one:

I/CSLIB: Contentsquare SDK 4.28.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.

For best implementation practices of our library, explore the Contentsquare for Android sample app.

Our 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.