• Home
  • All
  • How to get started with the e-Marketer Android SDK

Table of Contents

How to get started with the e-Marketer Android SDK

  1. First you need to download the SDK files from here.
  2. Start Android Studio. I will use version 3.3.2. Create new project. Select “Phone and Tablet” > “Empty Activity” and click “Next”.
  3. Enter desired project name, or leave as suggested and click “Finish”.
  4. Unzip the SDK. There must be directory called “emarketerandroidsdk”. Put it to the project root directory.
  5. In the Project window on the left, where project files are listed, notice “Gradle Scripts”, expand it and edit the “settings.gradle” file.

It’s initial content looks like this:

include ':app'

Change to:

include ':app', ':emarketerandroidsdk'

The IDE will prompt to sync the file. Click “Sync Now”.

  1. Find “app/build.gradle” file. This file starts with this line: “apply plugin: ‘com.android.application’”. In the “dependencies” section add this line
implementation project(path: ':emarketerandroidsdk')
  1. The IDE again will prompt to sync the file, so do it again.
  2. Your app must have INTERNET permission, so add it. In the “app/src/main/AndroidManifest.xml” file, in “<manifest>” tag, add
<uses-permission android:name="android.permission.INTERNET" />

Some applications also will need to add the following “uses-library” to “app/src/main/AndroidManifest.xml”:

<application
	...>
	<uses-library
			android:name="org.apache.http.legacy"
			android:required="false" />

This is according to https://developers.google.com/maps/documentation/android-sdk/config#specify_requirement_for_apache_http_legacy_library

Now the SDK must be usable.

To be sure add this code to your MainActivity, or elsewhere:

Tracker.inst.initialize(this, "0011223344556677889900112233445566778899");
Tracker.inst.navigate("MainActivity");
Tracker.inst.done();

Use your API key instead of “0011223344556677889900112233445566778899”. API keys for your account can be found on e-Marketer in the “Settings” → “Integrations” page here. You need the full-featured key.

The code above logs a navigation to page called “MainActivity”.

You can look up this request on e-Marketer Live Visits Dashboard. In filters, select “Pages” → “only containing” → “MainActivity”.