• No results found

Adobe Marketing Cloud Android SDK 4.x for Marketing Cloud Solutions

N/A
N/A
Protected

Academic year: 2021

Share "Adobe Marketing Cloud Android SDK 4.x for Marketing Cloud Solutions"

Copied!
88
0
0

Loading.... (view fulltext now)

Full text

(1)

Adobe

®

Marketing Cloud

(2)

Contents

Android SDK 4.x for Marketing Cloud Solutions...5

Release Notes for Android SDK 4.x for Marketing Cloud Solutions...6

Getting Started...8

Before You Start...8

Core Implementation and Lifecycle...9

Processing Rules and Context Data...11

Configuration...13

ADBMobile JSON Config...13

Override the ADBMobile JSON Config Path...20

Hit Batching...20

Configuration Methods...21

Analytics...26

Track App States...26

Track App Actions...27

Track App Crashes...29

Timed Actions...31

Visitor Lifetime Value...32

Products Variable...33

Products Variable with Merchandising eVars and Product-Specific Events...34

Event Serialization...35

Video Analytics...35

Postbacks...39

Postbacks Example...40

Analytics Methods...41

Android SDK 4.x for Marketing Cloud Solutions Last updated 9/15/2015

(3)

Acquisition...45

Mobile App Acquisition...45

Acquisition Methods...46

Messaging...47

In-app Messaging...47

Push Messaging...49

Location...51

Geo-Location and Points of Interest...51

Beacon tracking...53

Target...55

Target Configuration...55

Target Methods...55

Marketing Cloud...58

Marketing Cloud Visitor ID Configuration...58

Marketing Cloud Visitor ID Service Methods...58

Audience Manager...60

Audience Manager Configuration...60

Audience Manager Methods...60

Lifecycle Metrics...62

Wearables...67

Android Wearable Implementation...67

Android SDK Reference...70

App IDs...70

Visitor Tracking Between an App and Mobile Web...70

Android SDK 4.x for Marketing Cloud Solutions Last updated 9/15/2015

(4)

Android Widgets...71

Opt-Out and Privacy Settings...72

Using Bloodhound to Test Mobile Applications...73

PhoneGap Plug-in...74

PhoneGap Plug-in Methods...75

4.x Migration Guide...80

Documentation Updates...84

Historical Release Notes...86

Contact and Legal Information...88

Android SDK 4.x for Marketing Cloud Solutions Last updated 9/15/2015

(5)

Android SDK 4.x for Marketing Cloud Solutions

Android SDK 4.x for Marketing Cloud Solutions lets you measure native Android applications, deliver targeted content within your app, and leverage and collect audience data through audience management.

Last Update: September 17, 2015

Version 4.6 of the SDK is now available! See Release Notes for Android SDK 4.x for Marketing Cloud Solutions. This SDK supports Android 2.2 or later.

Note: In version 4.2 and later, all hits are now sent using HTTP POST. This has no impact on the data that is collected or reported, but you'll need to use a packet analyzer that supports inspecting POST data to view hits, such as the Bloodhound 3 beta.

If you are upgrading from a previous version, you'll want to take a look at the 4.x Migration Guide.

Adobe Mobile Services

Adobe Mobile services provides a new UI that brings together mobile marketing capabilities for mobile applications from across the Adobe Marketing Cloud. Initially, the Mobile service provides seamless integration of app analytics and targeting capabilities from the Adobe Analytics and Adobe Target solutions.

Learn more at Adobe Mobile Services documentation.

5 Android SDK 4.x for Marketing Cloud Solutions

(6)

Release Notes for Android SDK 4.x for Marketing Cloud

Solutions

Release notes and known issues for Android SDK 4.x for Marketing Cloud Solutions. This section contains the following information:

Current Release Notes

Marketing Cloud Release Notes, Documentation Updates, and Historical Release Notes

Current Release Notes

The Android SDK version 4.6 (September 17, 2015) includes the following changes:

Description Feature

Adobe Mobile Services and the Adobe Mobile SDK allow you to send push messages to Analytics segments. The SDK also allows you to easily report users that have opened your app as a result of opening the push message.

Push Messaging to Analytics Segments

See Push Messaging.

Allows developers to start an app acquisition campaign as if the user had clicked a link. This is helpful for creating manual acquisition links and handling the app store redirect yourself. Acquisition Methods

See Acquisition.

Postback Signals let you send data collected by the SDK to a separate third-party server. Leveraging the same triggers and traits you use to display an in-app message, you can configure the SDK to send customized data to a third-party destination.

Postbacks

See Postbacks.

Added the following new identifiers: Identifiers

• The setPushIdentifier method in Configuration Methods.

• The submitAdvertisingIdentifierTask method in Configuration Methods.

Marketing Cloud Release Notes, Documentation Updates, and Historical Release Notes

In addition to the notes for each release, the following resources provide additional information:

Description Resource

View the latest release notes for the Adobe Marketing Cloud solutions.

Marketing Cloud Release Notes

View detailed information about updates to this guide that might not be included in these release notes.

Documentation Updates

6 Release Notes for Android SDK 4.x for Marketing

(7)

Description Resource

View information about new features and enhancements in previous releases of Android SDK 4.x for Marketing Cloud Solutions.

Historical Release Notes

7 Release Notes for Android SDK 4.x for Marketing

(8)

Getting Started

Information to help you get starting with the Android SDK for Marketing Cloud Solutions.

Before You Start

Complete these steps to configure a report suite to collect app data.

If you are an Analytics administrator: Complete the steps in Set up your App in Adobe Mobile Services to configure a report suite to collect mobile app data. After you complete these steps, create an Analytics account for each app developer and give them access to view the report suite(s) you created.

If you are an app developer: Send a link to this page to your Analytics administrator and ask him or her to complete these steps.

After the report suite is configured, your administrator will provide you with a login you can use to complete steps in Download the SDK and Testing Tools.

This section contains the following information: •Set up your App in Adobe Mobile Services

Download the SDK and Testing Tools

Set up your App in Adobe Mobile Services

Note: You must be an Analytics Administrator to complete these steps.

Adobe Mobile services is the primary reporting interface for mobile app analytics and targeting. After you complete these steps you can download a configuration file that is pre-configured with your data collection server, report suite, and many other settings.

First, sign in at https://mobilemarketing.adobe.com. Two ways exist for you to sign in:

• Marketing Cloud: Sign in to the Marketing Cloud with your Adobe ID. This method assumes that your company has been

provisioned in the Marketing Cloud, and you have linked your Analytics account. (If you are unsure, use your existing Adobe Analytics account.)

• Adobe Analytics: Click Sign in with Analytics provide your Analytics company, username, and password.

Complete the following steps to set up a new report suite to collect app data and to define an app in Adobe Mobile services. 1. Click the Create New App button. (If you don't see this button, click Manage Apps > Add instead.)

2. From the Report Suite drop-down, select New Report Suite.

3. Provide the name of your App and select a unique report suite ID, for example, mycomobileappdev. Note that you'll need

to set up separate report suites and apps for the development and production versions, so you can repeat these steps when you are ready to set up the production version.

4. Leave Mobile App Template selected. This template enables timestamps to collect offline data and activates the mobile solution variables to capture lifecyle metrics.

5. Select your Timezone and Currency, and then click Save.

Download the SDK and Testing Tools

After an Analytics Administrator has completed the previous steps, complete the following to download the mobile SDKs. 1. Browse to https://mobilemarketing.adobe.com and log-in the with the account your administrator created for you. 2. Select your App from the drop-down list in the left navigation.

3. Click the Gear icon to open the App configuration.

8 Getting Started

(9)

4. Scroll to bottom of the page and download the SDK, Bloodhound, and the Sample App for your platform. A config file for your App is included in the SDK download automatically, so you don't need to download that separately unless you have already downloaded the SDK and you just want to get updated settings.

Core Implementation and Lifecycle

Information to help you implement the Android library and collect lifecyle metrics (launches, upgrades, sessions, engaged users, and so on).

This section contains the following information: •Core Implementation and Lifecycle

Add the SDK and Config File to your Project (IntelliJ IDEA)

Add the SDK and Config File to your Project (Eclipse)

Add App Permissions

Implement Lifecycle Metrics

Get the SDK

Requires Android 2.2 or later.

Complete the steps in Before You Start to set up a development report suite and download a pre-populated version of the configuration file.

After unzipping the [Your_App_Name_]AdobeMobileLibrary-4.*-Android.zip download file, you'll have the following software components:

•adobeMobileLibrary.jar: Library designed for use with Android devices and simulators. •ADBMobileConfig.json: SDK configuration file customized for your app.

Note: If you download the SDK outside of the Adobe Mobile services UI, the ADBMobileConfig.json must be manually configured. If you are new to Analytics and the mobile SDK, we highly recommend using the steps in Before You Start to set up a development report suite and download a pre-populated version of the configuration file. Configuration is not difficult, but it can be a source of frustration when you are getting started.

Add the SDK and Config File to your Project (IntelliJ IDEA)

For IntelliJ users:

1. Add the ADBMobileConfig.json file to the assets folder of your project. 2. Right click your project in the Project navigation panel.

3. Select Open Module Settings.

4. Select Libraries under Project Settings. 5. Click + icon to add a new library.

6. Select Java and navigate to the adobeMobileLibrary.jar file. 7. Select the modules where you plan to use the mobile library. 8. Click Apply, and then OK to close the Module Settings window.

Add the SDK and Config File to your Project (Eclipse)

For Eclipse users:

1. Add the ADBMobileConfig.json file to the assets folder of your project.

9 Getting Started

(10)

2. In the Eclipse IDE, right-click on the project name. 3. Select Build Path > Add External Archives. 4. Select adobeMobileLibrary.jar. 5. Click Open.

6. Right-click the project again, then select Build Path > Configure Build Path. 7. Click the Order and Export tab.

8. Ensure that adobeMobileLibrary.jar is selected.

Add App Permissions

The AppMeasurement Library requires the following permissions to send data and record offline tracking calls: •INTERNET

•ACCESS_NETWORK_STATE

To add these permissions, add the following lines to your AndroidManifest.xml file (in the application project directory):

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Implement Lifecycle Metrics

After you enable lifecycle, each time your app is launched, a single hit is sent to measure launches, upgrades, sessions, engaged users, and many other Lifecycle Metrics.

In your main activity:

1. Import the library:

import com.adobe.mobile.*;

2. Within the onCreate method, allow the SDK access to your application context using Config.setContext:

@Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

setContentView(R.layout.main);

// Allow the SDK access to the application context Config.setContext(this.getApplicationContext()); }

3. Within the onResume function, begin collecting lifecycle data: @Override

public void onResume() {

Config.collectLifecycleData(this);

// -or- Config.collectLifecycleData(this, contextData); }

4. Within the onPause function, pause collecting lifecycle data: @Override

public void onPause() {

Config.pauseCollectingLifecycleData(); }

In Each activity within your application:

1. Import the library:

import com.adobe.mobile.*;

10 Getting Started

(11)

2. Within the onResume function, begin collecting lifecycle data: @Override

public void onResume() {

Config.collectLifecycleData(this);

// -or- Config.collectLifecycleData(this, contextData); }

3. Within the onPause function, pause collecting lifecycle data:

@Override

public void onPause() {

Config.pauseCollectingLifecycleData(); }

It is essential that you add these calls to every activity to ensure accurate crash reporting.

Including Additional Data with Lifecycle Calls

To include additional data with lifecycle metric calls, pass an additional parameter to collectLifecycleData that contains

context data:

@Override

public void onResume() {

HashMap<String, Object> contextData = new HashMap<String, Object>(); contextData.put("myapp.category", "Game");

Config.collectLifecycleData(this, contextData); }

Additional context data values that are sent with collectLifecycleData must be mapped to custom variables in Adobe Mobile services:

Other Lifecycle Metrics are collected automatically. What to do next:

Track App States

Track App Actions

Processing Rules and Context Data

Processing rules are used to copy the data you send in context data variables to evars, props, and other variables for reporting.

Processing Rules Training @ Summit 2013

Processing Rules Help

11 Getting Started

(12)

Become authorized to use Processing Rules

We recommend grouping your context data variables using "namespaces", as it helps you keep logical ordering. For example, if you want to collect info about a product, you might define the following variables:

"product.type":"hat" "product.team":"mariners" "product.color":"blue"

Context data variables are sorted alphabetically in the processing rules interface, so namespaces let you quickly see variables that are in the same namespace.

We recommend that you avoid naming context data keys using the evar or prop number:

"eVar1":"jimbo"

This might make it slightly easier when you perform the one time mapping in processing rules, but you lose readability during debugging and future code updates can be more difficult. Instead, we strongly recommend using descriptive names for keys and values:

"username":"jimbo"

Context variables that define counter events should be set to 1:

"logon":"1"

Context data variables that define incrementor events can have the event as the key and the amount to increment as the value:

"levels completed":"6"

Note: Adobe reserves the namespace "a.". Aside from that small restriction, context data variables just need to be unique in your login company to avoid collisions.

12 Getting Started

(13)

Configuration

Information to help you configure the Android SDK, including JSON configuration, hit batching, and SDK methods.

ADBMobile JSON Config

Information to help you use the ADBMobile JSON Config file.

ADBMobileConfig.json Config File Reference

The same config file can be used for your app across multiple platforms.

iOS: The ADBMobileConfig.json can be placed anywhere that it is accessible in your bundle.

Android: The ADBMobileConfig.json must be placed in the assets folder.

Description Minimum

SDK Version Variable

Enables mobile app acquisition. 4.1

acquisition

server - Acquisition server that is checked at the initial launch for an acquisition referrer. appid - Generated ID that uniquely identifies this app on the acquisition server. If this section is missing, you need to enable Mobile App acquisition and then re-download the SDK configuration file.

See also: referrerTimeout

Enables/disables the ability for the Adobe SDK to backdate session info hits. Session info hits currently consist of crashes and session length.

4.6 backdateSessionInfo

The default is false.

When enabled, the Adobe SDK will backdate the session info hit to 1 second after the last hit of the previous session. This means that crashes and session data will correlate with the correct date in which they happened. This does, however, have a side effect in which it might create a visit for the backdated hit. One hit will be backdated on every new launch of the application.

Be aware that backdated session hit information is sent in a session info server call. Additional server calls may apply.

When disabled, the Adobe SDK will attach the session info to the current lifecycle. Threshold for number of hits to be sent in consecutive calls. For example, if batchLimit

is set to 10, each hit prior to the 10th hit will be stored in the queue. Once the 10th hit comes in, all 10 hits will be sent consecutively

4.1 batchLimit

Default: 0 (Batching not enabled) Requires offlineEnabled = true

13 Configuration

(14)

Description Minimum

SDK Version Variable

Defines the character set you are using for the data sent to Analytics. The charset is used to convert incoming data into UTF-8 for storage and reporting. See Using the charSet Property.

4.0 charset

(Required by Target) Your assigned client code. 4.0

clientCode

Default: 300 seconds 4.0

lifecycleTimeout

Specifies the length of time, in seconds, that must elapse between app launches before the launch is considered a new session. This timeout also applies when your application is sent to the background and reactivated. The time that your app spends in the background is not included in the session length.

Generated automatically by Adobe Mobile services, defines the settings for in-app messaging. For details, see Messages description.

4.2 messages

When enabled, hits are queued while the device is offline and sent later when the device is online. Your report suite must be timestamp-enabled to use offline tracking.

4.0 offlineEnabled

Default: false

Important: If timestamps are enabled on your report suite, your offlineEnabled configuration property must be true. if your report suite is not timestamp enabled, your offlineEnabled configuration property must be false. If this is not configured correctly, data will be lost. If you are not sure if a report suite is timestamp enabled,

contact Customer Care or download the configuration file from Adobe Mobile services.

If you are currently reporting AppMeasurement data to a report suite that also collects data from JavaScript, you might need to set up a separate report suite for mobile data, or include a custom timestamp on all JavaScript hits using the s.timestamp variable. Specifies the Marketing Cloud org ID for the visitor ID service.

4.3 org

Each POI array holds the POI name, latitude, longitude, and radius (in meters) for the area of the point. The POI name can be any string.

4.0 poi

When a trackLocation call is sent, if the current coordinates are within a defined POI,

a context data variable is populated and sent with the trackLocation call.

"poi" : [

["san francisco",37.757144,-122.44812,7000], ["santa cruz",36.972935,-122.01725,600] ]

Note: Starting in version 4.2, POIs are defined in the Adobe Mobile interface and then synchronized dynamically to the app configuration file. This synchronization requires the analytics.poi setting:

“analytics.poi”: “https://assets.adobedtm.com/…/yourfile.json”,

14 Configuration

(15)

Description Minimum

SDK Version Variable

If this is not configured, the ADBMobile.json file must be updated to include this line. See "Before you Start" to download an updated configuration file.

The definition for the "callback" message template is shown below:

"payload": {

"templateurl": "", // required - will be token-expanded prior to

4.6 postback

being sent

"templatebody": "", // optional - if this length > 0 POST will be used as transport method. This is a base64 encoded blob, which will be decoded and token-expanded prior to being sent.

"contenttype": "", // optional - if this is length > 0 and POST type is selected this will be set as the Content-Type header. if this is not supplied for a POST request, the default will be "application/x-www-form-urlencoded"

"timeout": 0 // optional - number of seconds to wait before timing out. Default is 2.

}

The payload object in the code is an example payload for a message definition that would

go in ADBMobileConfig.json.

For more information, see the applicable topic: • Android: Postbacks

• iOS: Postbacks

Default: optedin

4.0 privacyDefault

•optedin - hits are sent immediately.

•optedout - hits are discarded.

•optunknown - If your report suite is timestamp-enabled, hits are saved until the privacy

status changes to opt-in (then hits are sent) or opt-out (then hits are discarded). If your report suite is not timestamp-enabled, hits are discarded until the privacy status changes to opt in.

This sets the initial value only. If this value is ever set or changed in code, then the new value is used going forward until it is changed, or the app is uninstalled and then reinstalled. (Required by acquisition) Number of seconds the SDK waits for acquisition referrer data on the initial launch before timeout. If you are using acquisition, we recommend a 5 second timeout.

4.1 referrerTimeout

If set to 0 or if not included, the SDK does not wait for acquisition data and acquisition metrics are not tracked.

Configured automatically, defines the Adobe hosted endpoints for dynamic configuration files. The last update time of each configuration file is checked against the current version at each launch, and any updates are downloaded and saved.

4.2 remotes

analytics.poi - endpoint for hosted POI configuration.

15 Configuration

(16)

Description Minimum

SDK Version Variable

messages - endpoint for hosted in-app message configuration.

(Required by Analytics) One or more report suites to receive Analytics data. Multiple report suite IDs should be comma-separated with no space between.

"rsids" : "rsid"

"rsids" : "rsid1,rsid2"

4.0 rsids

(Required by Analytics and/or Audience Management). Analytics or Audience Management server, based on the parent node.

4.0 server

This variable should be populated with the server domain, without an "http://" or https://" protocol prefix. The protocol prefix is handled automatically by the library based on the

ssl variable.

If ssl is true, a secure connection is made to this server. If ssl is false, a non-secure connection is made to this server.

Default: false 4.0

ssl

Enables (true) or disables (false) sending measurement data via SSL (HTTPS). The definition for the "callback" message template is shown below:

"payload": {

"templateurl": "", // required - will be token-expanded prior to being sent

"templatebody": "", // optional - if this length > 0 POST will be used as transport method. This is a base64 encoded blob, which will be decoded and token-expanded prior to being sent.

"contenttype": "", // optional - if this is length > 0 and POST type is selected this will be set as the Content-Type header. if this is not supplied for a POST request, the default will be "application/x-www-form-urlencoded"

"timeout": 0 // optional - number of seconds to wait before timing out. Default is 2.

}

The payload object in the code is an example payload for a message definition that would go in ADBMobileConfig.json.

For more information, see the applicable topic: • Android: Third-Party Callback

• iOS: Third-Party Callback

Determines how long Target waits for a response. 4.0

timeout

The following is an example of an ADBMobileConfig.json file:

{ "version": "2014-08-05T19:18:28.169Z", "marketingCloud" : { "org": "016D5C175213CCA80A490D05@AdobeOrg" 16 Configuration

(17)

}, "target": { "clientCode": "", "timeout": 5 }, "audienceManager": { "server": "" }, "acquisition": { "server": "c00.adobe.com", "appid": "10a77a60192fbb628376e1b1daeeb65debf934e2c807e067ceb2963a41b165ee" }, "analytics": { "rsids": "coolApp", "server": "my.CoolApp.com", "ssl": false, "offlineEnabled": true, "charset": "UTF-8", "lifecycleTimeout": 300, "privacyDefault": "optedin", "batchLimit": 0, "referrerTimeout": 5, "poi": [ ["san francisco",37.757144,-122.44812,7000], ["santa cruz",36.972935,-122.01725,600] ] }, "messages": [ { "messageId": "cb426565-a563-497a-a889-9dbeb451f8ae", "template": "fullscreen", "payload": {

"html": "<!DOCTYPE html><html><head><meta charset=\"utf-8\" /><title></title><style></style></head><body><iframe src=\"http://www.adobe.com/\" frameborder=\"0\"></iframe></body></html>" }, "showOffline": false, "showRule": "always", "endDate": 2524730400, "startDate": 0, "audiences": [], "triggers": [ { "key": "pev2", "matches": "eq", "values": [ "AMACTION:custom" ] } ] } ], "remotes": { "analytics.poi": "https://assets.adobedtm.com/staging/42a6fc9b77cd9f29082cf19b787bae75b7d1f9ca/scripts/satellite-53e0faadc2f9ed92bc00003b.json", "messages": "https://assets.adobedtm.com/staging/42a6fc9b77cd9f29082cf19b787bae75b7d1f9ca/scripts/satellite-53e0f9e2c2f9ed92bc000032.json" } } Messages description

The messages node is generated automatically by Adobe Mobile services and typically does not need to be manually changed. The following description is provided for troubleshooting purposes:

• "messageId"

17 Configuration

(18)

• Generated ID, required• • "template"

• "alert", "fullscreen", or "local"• • required

• "showOffline" • true or false•

• default is false • "showRule"

• "always", "once", or "untilClick"• • required

• "endDate"

• number of seconds since Jan 1, 1970• • default is 2524730400

• "startDate"

• number of seconds since Jan 1, 1970• • default is 0

• "payload" • "html"•

• fullscreen template only, required• • html defining the message • "image"

• fullscreen only, optional•

• url to the image to be used for a fullscreen image • "altImage"

• fullscreen only, optional•

• name of the bundled image to use if the url specified in image

is unreachable • "title"

• fullscreen and alert, required•

• title text for a fullscreen or alert message • "content"

• alert and local notification, required•

18 Configuration

(19)

• sub-text for an alert message, or notification text for a local notification message • "confirm"

• alert, optional•

• text used in the confirm button • "cancel"

• alert, required•

• text used in the cancel button • "url"

• alert, optional•

• url action to load if the confirm button is clicked • "wait"

• • local notification, required

• amount of time to wait (in seconds) to post the local notification after matching its criteria • "audiences"

• array of objects that defines how the message should be shown• • "key"

• variable name to look for in the hit, required• • "matches"

• type of matcher used when doing the comparison• • • eq = equals

• ne = does not equal • co = contains • nc = does not contain • sw = starts with • ew = ends with • ex = exists

• nx = does not exist • lt = less than

• le = less than or equals • gt = greater than

• ge = greater than or equals • "values"

• • an array of values used to match against the value of the variable named in

19 Configuration

(20)

key

with the matcher type in matches

• "triggers"

• same as audiences, but this is the action instead of the audience• • "key"

• "matches" • "values"

Override the ADBMobile JSON Config Path

Load a different ADBMobile JSON Config file when the application starts.

The Config.overrideConfigStream(configInput) method enables you to specify the path to a different ADBMobile.json

configuration file when the application starts. This method must be called before any other Marketing Cloud SDK call (before

Config.collectLifecycleData() ), likely in the onCreate method of your first loaded activity.

Calling this method with a different path causes a one-time override of the configuration file until the application is closed.

try {

InputStream configInput = getAssets().open("ExampleJSONFile.json"); Config.overrideConfigStream(configInput);

} catch (IOException ex) {

// do something with the exception if needed }

Hit Batching

Hit batching allows applications with offline tracking enabled to hold hits from being sent until the number of hits in the queue pass a configurable limit.

Requires SDK version 4.1 or later

To enable hit batching, you need to update your ADBMobileConfig.json and specify a value for batchLimit:

"analytics": { "batchLimit": 5, ...

}

When set to a number higher than 0, the SDK queues the number of hits equal to batchLimit. After this threshold is passed, all hits in the queue are sent.

The following methods are used in conjunction with hit batching:

•Analytics.getQueueSize() - Returns a long with the number of hits currently in the hit batching queue.

•Analytics.sendQueuedHits() - Forces the library to send all hits in the queue no matter how many are currently queued. •Analytics.clearQueue() - Clears all hits from the queue without sending them.

: Offline tracking must be enabled to use hit batching.

20 Configuration

(21)

Configuration Methods

List of methods provided by the Android library. This section contains the following information: •Initial Configuration

SDK Settings (Config Class)

Initial Configuration

The following method must be called once in the onCreate() method of your main activity. Description

Method

Example: @Override

public void onCreate(Bundle savedInstanceState) {

setContext

super.onCreate(savedInstanceState); setContentView(R.layout.main);

Config.setContext(this.getApplicationContext()); }

SDK Settings (Config Class)

Description Method

Returns the current version of the Adobe Mobile library. getVersion

Syntax:

public static String getVersion(); Example:

String libraryVersion = Config.getVersion();

Returns the enum representation of the privacy status for current user. getPrivacyStatus

•MOBILE_PRIVACY_STATUS_OPT_IN - hits are sent immediately. •MOBILE_PRIVACY_STATUS_OPT_OUT - hits are discarded.

•MOBILE_PRIVACY_STATUS_UNKNOWN - If your report suite is timestamp-enabled, hits are saved until the privacy status changes to opt-in (then hits are sent) or opt-out (then hits are discarded). If your report suite is not timestamp-enabled, hits are discarded until the privacy status changes to opt in.

Default: The default value is set in ADBMobileConfig.json

Syntax:

public static MobilePrivacyStatus getPrivacyStatus(); Example:

MobilePrivacyStatus privacyStatus = Config.getPrivacyStatus();

Sets the privacy status for the current user to status. Set to one of the following values:

setPrivacyStatus

21 Configuration

(22)

Description Method

•MOBILE_PRIVACY_STATUS_OPT_IN - hits are sent immediately.

•MOBILE_PRIVACY_STATUS_OPT_OUT - hits are discarded.

•MOBILE_PRIVACY_STATUS_UNKNOWN - If your report suite is timestamp-enabled, hits are

saved until the privacy status changes to opt-in (then hits are sent) or opt-out (then hits are discarded). If your report suite is not timestamp-enabled, hits are discarded until the privacy status changes to opt in.

Syntax:

public static void setPrivacyStatus(MobilePrivacyStatus status); Example:

Config.setPrivacyStatus(MobilePrivacyStatus.MOBILE_PRIVACY_STATUS_OPT_IN);

Returns the lifetime value of the current user. getLifetimeValue

Default: 0

Syntax:

public static BigDecimal getLifetimeValue(); Example:

BigDecimal currentLifetimeValue = Config.getLifetimeValue();

Returns the custom user identifier if a custom identifier has been set. Returns null if a custom identifier is not set.

getUserIdentifier

Default: null

Note: If your app upgrades from the Marketing Cloud 3.x to 4.x SDK, the previous visitor ID (either custom or automatically generated) is retrieved and stored as the custom user identifier. This preserves visitor data between upgrades of the SDK. For new installations on the 4.x SDK, user identifier is null until set.

Syntax:

public static String getUserIdentifier(); Example:

String userId = Config.getUserIdentifier();

Sets the user identifier to identifier.

setUserIdentifier

Syntax:

public static void setUserIdentifer(String identifier); Example:

Config.setUserIdentifier("billybob");

Returns the current debug logging preference. getDebugLogging

Default: false

22 Configuration

(23)

Description Method

Syntax:

public static Boolean getDebugLogging(); Example:

Boolean debugging = Config.getDebugLogging();

Sets the debug logging preference to debugLogging. setDebugLogging

Syntax:

public static void setDebugLogging(Boolean debugLogging); Example:

Config.setDebugLogging(true);

Indicates to the SDK that lifecycle data should be collected for use across all solutions in the SDK. See Lifecycle Metrics.

collectLifecycleData

Syntax:

public static void collectLifecycleData(final Activity activity, final Map<String, Object> contextData);

Example:

Without extra context data:

@Override

protected void onResume() { super.onResume();

Config.collectLifecycleData(this); }

With extra context data:

@Override

public void onResume() {

HashMap<String, Object> contextData = new HashMap<String, Object>(); contextData.put("myapp.category", "Game");

Config.collectLifecycleData(this, contextData); }

(4.2 or later) Indicates to the SDK that lifecycle data should be collected for use across all solutions in the SDK. See Lifecycle Metrics.

collectLifecycleData (Activity activity)

Syntax:

public static void collectLifecycleData(final Activity activity); Example:

@Override

protected void onResume() { super.onResume();

// assumes being called in an Activity class Config.collectLifecycleData(this);

}

23 Configuration

(24)

Description Method

Indicates to the SDK that your app is paused, so that lifecycle metrics are calculated correctly. For example, on pause collects a timestamp to determine previous session length. This also sets a flag so that lifecycle correctly knows that the app did not crash. See Lifecycle Metrics. pauseCollectingLifecycleData

Syntax:

public static void pauseCollectingLifecycleData(); Example:

@Override

protected void onPause() { super.onPause();

Config.pauseCollectingLifecycleData(); }

(4.2 or later) Set the small icon that will be used for notifications created by the SDK. This icon will show up in the status bar. This will also be the secondary image shown when the user sees the full notification in the notification center.

setSmallIconResourceId(int resourceId)

Syntax:

public static void setSmallIconResourceId(final int resourceId); Example:

Config.setSmallIconResourceId(R.drawable.appIcon);

(4.2 or later) Set the large icon that will be used for notifications created by the SDK. This icon will be the primary image shown when the user sees the full notification in the notification center.

setLargeIconResourceId(int resourceId)

Syntax:

public static void setLargeIconResourceId(final int resourceId); Example:

Config.setLargeIconResourceId(R.drawable.appIcon);

(4.2 or later) Lets you load a different ADBMobile JSON Config file when the application starts. The different configuration is used until the application is closed.

overrideConfigStream(InputStream configInput)

Syntax:

public static void overrideConfigStream(final InputStream configInput); Example:

try {

InputStream configInput = getAssets().open("ExampleJSONFile.json"); Config.overrideConfigStream(configInput);

} catch (IOException ex) {

// do something with the exception if needed }

Sets the device token for push notifications. setPushIdentifier

24 Configuration

(25)

Description Method

Syntax:

public static void setPushIdentifier(final String registrationId); Example:

...

// note: the code to retreive the push token must run in the background InstanceID instanceID = InstanceID.getInstance(getApplicationContext()); String token = instanceID.getToken("835015092242",

GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); Config.setPushIdentifier(token);

...

Provide a Callable to the SDK that returns the string of the Advertising Identifier returned from Google Play Services. The SDK runs this task on a background thread and sets an internal variable for Advertising Identifier based on the value returned from the Callable.

submitAdvertisingIdentifierTask

Note, if you want to use Advertising Identifier in Acquisition or Lifecycle, you must call it before calling Config.collectLifecycleData.

Syntax:

public static void submitAdvertisingIdentifierTask(final Callable<String> task);

Example: @Override

public void onResume() { super.onResume();

final Callable<String> task = new Callable<String>() { @Override

public String call() throws Exception { AdvertisingIdClient.Info idInfo; String adid = null;

Context appContext = CLASSNAME.this.getApplicationContext();

try { idInfo = AdvertisingIdClient.getAdvertisingIdInfo(appContext); if (idInfo != null) { adid = idInfo.getId(); }

} catch (Exception ex) {

Log.e("Error", ex.getLocalizedMessage()); } return adid; } }; Config.submitAdvertisingIdentifierTask(task); Config.collectLifecycleData(this); } 25 Configuration

(26)

Analytics

Information to help you use the Android SDK with Adobe Analytics.

Track App States

States are the different screens or views in your application.

Each time a new state is displayed in your application (for example, when a user navigates from the home page to the news feed), you should send a trackState call. In Android, trackState is typically called each time a new Activity is loaded.

How to Track

Prerequisites: Add the library to your project and implement lifecycle. 1. Import the library:

import com.adobe.mobile.*;

2. Within the onCreate function, call trackState to send a hit for this state view: @Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

setContentView(R.layout.main);

// Adobe - track when this state loads Analytics.trackState("State Name", null); }

The "State Name" is reported in the View State variable in Adobe Mobile services, and a view is recorded for each trackState

call. In other Analytics interfaces, View State is reported as Page Name and state views is reported as page views.

Sending Additional Data

In addition to the "State Name", you can send additional context data with each track action call:

@Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

setContentView(R.layout.main);

// Adobe - track when this state loads

HashMap<String, Object> exampleContextData = new HashMap<String, Object>(); exampleContextData.put("myapp.login.LoginStatus", "logged in");

Analytics.trackState("Home Screen", exampleContextData); }

Context data values must be mapped to custom variables in Adobe Mobile services:

26 Analytics

(27)

App State Reporting

States are typically viewed using a pathing report so you can see how users navigate your app, and which states are viewed most. View States Report. This report is based on the paths users took through your application. For example, Login > Home > Settings, or Home > Feed.

Adobe Mobile Services

States can be viewed anywhere Pages can be viewed, such as the Pages Report, Page Views report, and Path Reports.

Adobe Analytics

States can be viewed anywhere Pages can be viewed using the Page dimension, Page Views metric, Path Reports.

Ad hoc analytics

Track App Actions

Actions are the events that occur in your app that you want to measure.

Each action has one or more corresponding metrics that are incremented each time the event occurs. For example, you might send a trackAction call for each new subscription, each time an article is viewed, or each time a level is completed. Actions are not tracked automatically, you must call trackAction when an event you want to track occurs, and then map the action to a custom event.

How to Track

Prerequisites: Add the library to your project and implement lifecycle. 1. Import the library:

import com.adobe.mobile.*;

2. When the action that you want to track occurs in your app, call trackAction to send a hit for this action: Analytics.trackAction("myapp.ActionName", null);

3. In Adobe Mobile services, select your app and click Manage App Settings. 4. Click Manage Variables and Metrics and then click the Custom Metrics tab.

5. Map the context data name defined in your code ("myapp.ActionName " in the example) to a custom event.

27 Analytics

(28)

You can also set a prop to hold all action values by mapping a custom prop with a name like "Custom Actions" and setting the value to 'a.action'.

Sending Additional Data

In addition to the action name, you can send additional context data with each track action call:

HashMap<String, Object> exampleContextData = new HashMap<String, Object>(); exampleContextData.put("myapp.social.SocialSource", "Twitter");

Analytics.trackAction("myapp.SocialShare", exampleContextData);

Context data values must be mapped to custom variables in Adobe Mobile services:

28 Analytics

(29)

Action Reporting

Report Interface

Action Paths Report. View the order in which actions occur in your app. Adobe Mobile Services

You can also click Customize on any report to view actions ranked, trended, or in a breakdown report. Apply a filter to view actions for a specific segment.

Custom Event Report. After an action is mapped to a custom event, you can view mobile events similar to all other Analytics events.

Marketing reports & analytics

Custom Event Report. After an action is mapped to a custom event, you can view mobile events similar to all other Analytics events.

Ad hoc analytics

Track App Crashes

App crashes are tracked as part of lifecycle metrics. To track crashes, add the library to your project and implement lifecycle. When lifecycle metrics are implemented, a call is made to Config.collectLifecycleData in the OnResume method of each activity. In the onPause method, a call is made to Config.pauseCollectingLifeCycleData.

Inside of the pauseCollectingLifeCycleData, a flag is set to indicate a graceful exit. When the app is relaunched or resumed, collectLifecycleData checks this flag for a graceful exit. If the app did not exit successfully (as determined by the flag status), an a.CrashEvent context data is sent with the next call and a crash event is reported.

To ensure accurate crash reporting, you must call the pauseCollectingLifeCycleData inside of the onPause method of each activity. To understand why this is essential, it is helpful to understand the Android activity lifecycle:

29 Analytics

(30)

If a call is not made to pauseCollectingLifeCycleData before your app is paused, when the user returns to your app or when your app is re-launched, the SDK reports a crash event since the flag is not set to indicate a graceful exit.

If Config.collectLifecycleData is called twice in a row during the same session (without a call to

pauseCollectingLifeCycleData in between), then a crash is reported on every call after the first. For example, if you forget

to add a call to pauseCollectingLifeCycleData to onPause for an activity, then a crash might be reported if the app is backgrounded during that activity.

(See http://developer.android.com/guide/components/activities.html for more information on Android activity lifecycle. The Android lifecycle image that appears on this page was created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License)

30 Analytics

(31)

Timed Actions

Timed actions let you measure in-app time and total time between the start and end of an action. The SDK calculates the amount of time in session and the total time (cross-session) it takes for the action to be completed. This can be used to define segments to compare on time to purchase, pass level, checkout flow, and so on.

The following metrics are reported for timed actions:

• Total # of seconds in app between start and end - cross sessions • Total # of seconds between start and end (clock time)

An optional callback allows you to take additional action when the timed action completes: • Run code and add any logic - optional custom logic based on duration results.

• Add context data prior to passing in durations. • Cancel hit and durations not yet sent.

How to Track

Prerequisites: Add the library to your project and implement lifecycle. 1. Import the library:

import com.adobe.mobile.*;

2. Call trackTimedActionStart and provide a timed action name and optional context data.

HashMap cdata = new HashMap<String, Object>(); cdata.put("ExperienceName", experience);

Analytics.trackTimedActionStart("TimeUntilPurchase", cdata);

3. (Optional) At any point, you can call trackTimedActionUpdate with the timed action name to add additional context

data.

HashMap cdata = new HashMap<String, Object>(); cdata.put("myapp.ImageLiked", imageName);

Analytics.trackTimedActionUpdate("TimeUntilPurchase", cdata);

4. When the event completes, call trackTimedActionEnd and pass the timed action name and TimedActionBlock (callback) which will look up all data and calculate durations. Timed event metrics are saved in mobile solution variables for automatic reporting.

Analytics.trackTimedActionEnd("TimeUntilPurchase", cdata);

Sending Additional Data

In addition to the timed action name, you can send additional context data with the action start and action update calls:

HashMap cdata = new HashMap<String, Object>(); cdata.put("myapp.ImageLiked", imageName);

Analytics.trackTimedActionUpdate("TimeUntilPurchase", cdata);

Context data values must be mapped to custom variables in Adobe Mobile services:

31 Analytics

(32)

Examples

// Timed Action Start Example

HashMap cdata = new HashMap<String, Object>(); cdata.put("ExperienceName", experience);

Analytics.trackTimedActionStart("TimeUntilPurchase", cdata); // Timed Action Update Example

cdata = new HashMap<String, Object>(); cdata.put("ImageLiked", imageName);

Analytics.trackTimedActionUpdate("TimeUntilPurchase", cdata); // Timed Action End Example

Analytics.trackTimedActionEnd("TimeUntilPurchase", null); // Timed Action End Example with Callback

Analytics.trackTimedActionEnd("TimeUntilPurchase", new Analytics.TimedActionBlock<Boolean>() {

@Override

public Boolean call(long inAppDuration, long totalDuration, Map<String, Object> contextData) {

contextData.put("PurchaseItem", "Item453");

return true; // return true to send the hit, false to cancel }

});

Visitor Lifetime Value

Lifetime value lets you measure and target on a lifetime value for each user.

Each time you send in a value with trackLifetimeValueIncrease, the value is added to the existing value. Lifetime value

is stored on device and can be retrieved at any time by calling lifetimeValue. This can be used to store lifetime purchases, ad views, video completes, social shares, photo uploads, and so on.

How to Track

Prerequisites: Add the library to your project and implement lifecycle. 1. Import the library:

import com.adobe.mobile.*;

2. Call trackLifetimeValueIncrease with the amount to increase the value:

Analytics.trackLifetimeValueIncrease(BigDecimal.valueOf(5.0), null);

32 Analytics

(33)

Sending Additional Data

In addition to the lifetime value, you can send additional context data with each track action call:

HashMap cdata = new HashMap<String, Object>(); cdata.put("myapp.ImageLiked", imageName);

Analytics.trackLifetimeValueIncrease(BigDecimal.valueOf(5.0), cdata);

Context data values must be mapped to custom variables in Adobe Mobile services:

Products Variable

The products variable cannot be set using processing rules. In the mobile SDK, you must use a special syntax within the context data parameter to set products directly on the server call.

To set the products variable, set a context data key to "&&products", and set the value using the syntax defined for the products

variable:

cdata.put("&&products", "Category;Product;Quantity;Price[,Category;Product;Quantity;Price]");

For example:

//create a context data dictionary

HashMap cdata = new HashMap<String, Object>();

// add products, a purchase id, a purchase context data key, and any other data you want to collect.

// Note the special syntax for products

cdata.put("&&products", ";Running Shoes;1;69.95,;Running Socks;10;29.99"); cdata.put("myapp.purchase", "1");

cdata.put("myapp.purchaseid", "1234567890");

// send the tracking call - use either a trackAction or TrackState call. // trackAction example:

Analytics.trackAction("purchase", cdata); // trackState example:

Analytics.trackState("Order Confirmation", cdata);

Note that products is set directly on the image request, and the other variables are set as context data:

33 Analytics

(34)

All context data variables must be mapped using processing rules:

You do not need to map the products variable using processing rules since it is set directly on the image request by the SDK.

Products Variable with Merchandising eVars and Product-Specific Events

An example of the products variable with Merchandising eVars and product-specific events.

//create a context data dictionary

HashMap cdata = new HashMap<String, Object>();

// add products, a purchase id, a purchase context data key, and any other data you want to collect.

// Note the special syntax for products cdata.put("&&events", "event1");

cdata.put("&&products", ";Running Shoes;1;69.95;event1=5.5;eVar1=Merchandising,;Running Socks;10;29.99");

cdata.put("myapp.purchase", "1");

cdata.put("myapp.purchaseid", "1234567890");

// send the tracking call - use either a trackAction or TrackState call. // trackAction example:

Analytics.trackAction("purchase", cdata);

34 Analytics

(35)

// trackState example:

Analytics.trackState("Order Confirmation", cdata);

Note: If you trigger a product-specific event using the &&products variable, you must also set that event in the &&events variable, otherwise the event is filtered out during processing.

Event Serialization

Event serialization is not supported by processing rules. In the mobile SDK, you must use a special syntax within the context data parameter to set serialized events directly on the server call.

See Event Serialization.

cdata.put("&&events", "event1:12341234");

For example:

//create a context data dictionary

HashMap cdata = new HashMap<String, Object>(); // add events

cdata.put("&&events", "event1:12341234");

// send the tracking call - use either a trackAction or TrackState call. // trackAction example:

Analytics.trackAction("action", cdata); // trackState example:

Analytics.trackState("State Name", cdata);

Video Analytics

This guide describes measuring video on Android using milestone video measurement.

Note: Adobe has a new video measurement solution called video heartbeat. During video playback, frequent "heartbeat" calls are sent to this service to measure time played. These heartbeat calls are sent every 10 seconds , which results in granular video engagement metrics and more accurate video fallout reports. See Measuring Video in Adobe Analytics using Video Heartbeat for details.

Additional information on milestone video measurement is available in the Measuring Video in Analytics guide. The general process to measure video is very similar across all platforms. This quick start section provides a basic overview of the developer tasks along with code samples.

Map Player Events to Analytics Variables

The following table lists the media data that is sent to Analytics. Use processing rules to map the context data in the Context Data Variable column to an Analytics variable as described in the Variable Type column.

Description Variable Type

Context Data Variable

(Required) Collects the name of the video, as specified in the implementation, when a visitor views the video in some way.You can add classifications for this variable.

eVar

Default expiration: Visit Custom Insight (s.prop, used for video pathing)

a.media.name

35 Analytics

(36)

Description Variable Type

Context Data Variable

(Optional) The Custom Insight variable provides video pathing information.

(Optional) Provides video pathing information. Pathing must be enabled for this variable by ClientCare.

Custom Insight (s.prop) a.media.name

Event type: Custom Insight (s.prop)

(Required) Collects video segment data, including the segment name and the order in which the segment occurs in the video. eVar

Default expiration: Page view a.media.segment

This variable is populated by enabling the

segmentByMilestones variable when tracking player events automatically, or by setting a custom segment name when tracking player events manually.

For example, when a visitor views the first segment in a video, SiteCatalyst might collect the following in the Segments eVar:

1:M:0-25

The default video data collection method collects data at the following points: video start (play), segment begin, and video end (stop). Analytics counts the first segment view at the start of the segment, when the visitor starts watching. Subsequent segment views as the segment begins.

Collects data about the type of content viewed by a visitor. Hits sent by video measurement are assigned a content type of "video". eVar

Default expiration: Page view a.contentType

This variable does not need to be reserved exclusively for video tracking. Having other content report content type using this same variable lets you analyze the distribution of visitors across the different types of content. For example, you could tag other content types using values such as “article" or “product page" using this variable.

From a video measurement perspective, Content Type lets you identify video visitors and thereby calculate video conversion rates.

Counts the time, in seconds, spent watching a video since the last data collection process (image request).

Event

Type: Counter a.media.timePlayed

Indicates that a visitor has viewed some portion of a video. However, it does not provide any information about how much, or what part, of a video the visitor viewed.

Event

Type: Counter a.media.view

36 Analytics

(37)

Description Variable Type

Context Data Variable

Indicates that a visitor has viewed some portion of a video segment. However, it does not provide any information about how much, or what part, of a video the visitor viewed. Event

Type: Counter a.media.segmentView

Indicates that a user has viewed a complete video. By default, the complete event is measured 1 second before the end of the video.

Event

Type: Counter a .media.complete

During implementation, you can specify how many seconds from the end of the video you would like to consider a view complete. For live video and other streams that don't have a defined end, you can specify a custom point to measure completes. For example, after a specific time viewed.

Configure Media Settings

Configure a MediaSettings object with the settings you want to use to track video:

MediaSettings mySettings = Media.settingsWith("name", 10, "playerName", "playerId");

Track Player Events

To measure video playback, The mediaPlay, mediaStop, and mediaClose methods need to be called at the appropriate times.

For example, when the player is paused, mediaStop. mediaPlay is called when playback starts or is resumed.

Classes

Class: MediaSettings public String name; public String playerName; public String playerID; public double length; public String channel; public String milestones; public String offsetMilestones; public boolean segmentByMilestones; public boolean segmentByOffsetMilestones; public int trackSeconds = 0;

public int completeCloseOffsetThreshold = 1; // MediaAnalytics Ad settings

public String parentName; public String parentPod; public String CPM;

public double parentPodPosition; public boolean isMediaAd;

Class: MediaState

public Date openTime = new Date(); public String name;

public String segment; public String playerName; public String mediaEvent; public int offsetMilestone; public int segmentNum;

37 Analytics

(38)

public int milestone; public double length; public double offset; public double percent; public double timePlayed; public double segmentLength; public boolean complete = false; public boolean clicked = false; public boolean ad;

public boolean eventFirstTime;

Media Measurement Class and Method Reference

Description Method

Returns a MediaSettings object with specified parameters. settingsWith

Syntax:

public static MediaSettings adSettingsWith(String name, double length, String playerName, String parentName, String parentPod, double

parentPodPosition, String CPM); Example:

MediaSettings mySettings = Media.settingsWith("name", 10, "playerName", "playerId");

Returns a MediaSettings object for use with tracking an ad video. adSettingsWith

Syntax:

public static MediaSettings adSettingsWith(String name, double length, String playerName, String parentName, String parentPod, double

parentPodPosition, String CPM); Example:

Opens a MediaSettings object for tracking.

open

Syntax:

public static void open(MediaSettings settings, MediaCallback callback); Example:

Media.open(mySettings, new Media.MediaCallback() { @Override

public void call(Object item) {

// monitor callback if you want to be notified every second the media is playing

} });

Closes the media item named name. close

Syntax:

public static void close(String name); Example:

Media.close("name");

38 Analytics

(39)

Description Method

Plays the media item named name at the given offset (in seconds). play

Syntax:

public static void play(String name, double offset); Example:

Manually mark the media item as complete at the offset provided (in seconds). complete

Syntax:

public static void complete(String name, double offset); Example:

Media.complete("name", 0);

Notifies the media module that the video has been stopped or paused at the given offset. stop

Syntax:

public static void stop(String name, double offset); Example:

Media.stop("name", 0);

Notifies the media module that the media item has been clicked. click

Syntax:

public static void click(String name, double offset); Example:

Media.click("name", 0);

Sends a track action call (no page view) for the current media state. track

Syntax:

public static void track(String name, Map<String, Object> data); Example:

Media.track("name", null);

Postbacks

Postbacks let you send data collected by the SDK to a separate third-party server. Leveraging the same triggers and traits you use to display an in-app message, you can configure the SDK to send customized data to a third-party destination.

Note: This functionality requires SDK version 4.6.0 or later.

39 Analytics

(40)

Postback messages are queued and follow all existing online/offline rules that govern analytics data collection. Note that postback messages do not cancel the rest of the messages if a message matches (like shown-messages do). This allows for multiple postbacks to occur on the same analytics hit.

See the "postbacks" row in ADBMobile JSON Config for the definition.

Template Expansions

Template expansions are available in both the templateurl and templatebody properties. Template items take the form of

"{key}", where "key" is a context-data key, or traditional data key. The values available for template expansion are limited to the

standard Lifecycle variables list, in addition to any custom data attached to the hit that triggers the message. No historical-based or segment-based data is available at this time.

There are also specific, reserved templates that the SDK will replace for you automatically with internal data known to the SDK. This list includes:

Token Description Token Name

Returns SDK version.

{%sdkver%}

Resolves to a random number between 1 and 100000000.

{%cachebust%}

Returns Advertiser ID for Android. Note, this only works if you have used

submitAdvertisingIdentifierTask.

{%adid%}

Returns the Push Identifier token. Note, this only works if you have used setPushIdentifier. {%pushid%}

Returns current timestamp in epoch time.

{%timestampu%}

Returns current timestamp in JavaScript (ISO 8601) format.

{%timestampz%}

Postbacks Example

Definition and source code examples for the Postbacks feature.

: This example is provided for informational purposes only. The ADBMobileConfig.json file should be configured in the Adobe Mobile UI. This file should not be modified manually. Using a manually edited configuration file is especially dangerous if you have remote messages configuration enabled.

This section contains the following information: •ADBMobileConfig.json DefinitionSource Code ADBMobileConfig.json Definition "messages": [ { "messageId": "79ae37c9-89b9-465e-af7f-d3351771f1dc", "template": "callback", "payload": { "templateurl": "http://my.server.com/?user={user.name}&zip={user.zip}&c16={%sdkver%}&c27=cln,{a.PrevSessionLength}", 40 Analytics

(41)

"templatebody": "c2RrdmVyPXslc2RrdmVyJX0mY2I9eyVjYWNoZWJ1c3QlfSZjbGllbnRJZD17bi5jbGllbnQuaWR9JnRzPXsldGltZXN0YW1wVSV9JnRzej17JXRpbWVzdGFtcFolfQ==", "contenttype": "application/x-www-form-urlencoded", "timeout": 4 }, "showOffline": true, "showRule": "always", "endDate": 2524730400, "startDate": 0, "audiences": [], "triggers": [ { "key": "pageName", "matches": "eq", "values": [ "MainMenu" ] } ] } ] Source Code

HashMap<String, Object> contextData = new HashMap<String, Object>(); contextData.put("user.name", "bob");

contextData.put("user.zip", "90210");

Analytics.trackState("MainMenu", contextData);

Due to the fact that its state is “MainMenu”, this tracking call triggers the above postback message. The URL will replace all template variables with values from the hit. Assuming that the user’s previous session was 132 seconds long and that user is on Android SDK version 4.6.0, the resulting URL would look like this:

http://my.server.com/?user=bob&zip=90210&c16=4.6.0-AN&c27=cln,132

Analytics Methods

List of Adobe Analytics methods provided by the Android library.

The SDK currently has support for multiple Adobe Marketing Cloud Solutions, including Analytics, Target, Audience Manager, and the Marketing Cloud Visitor ID Service. Methods are prefixed according to the solution. Marketing Cloud visitor ID methods are prefixed with "analytics."

Each of these methods is used to send data into your Adobe Analytics report suite.

Description Method

Tracks an app state with optional context data. States are the views that are available in your app, such as "home dashboard", "app settings", "cart", and so on. These states are similar to pages on a website, and trackState calls increment page views.

trackState

If state is empty, it displays as "app name app version (build)" in reports. If you see this value in reports, make sure you are setting state in each trackState call.

Note: This is the only tracking call that increments page views. Syntax:

public static void trackState(String state, Map<String, Object> contextData); 41 Analytics

References

Related documents

Therefore, the objective of the present study was to in- vestigate the influence of the ketamine anesthetic combined with xylazine in adult gerbils by measuring the latency of

developing and offering services based on the utilisation of digital information, it is possible to create and accelerate economic growth. Our success depends on that we

– PI Professor Jussi Vahtera Hospital personnel study - PI Professor Mika Kivimäki includes employees from 10 towns 6 hospital districts 20% of the public sector employees in

The trend observed for pristine XD composites of an initial decrease followed by a linear increase in thermal conductivity as nanotube weight fraction increases is also

Stakeholders in group programme development and delivery could use the findings of this research to reflect on the process of goal setting activities in their group programmes so they

Ovakvo antikonvencionalističko stajalište razumijevanja filma, koje ne polazi od figure gledatelja kao prazne ploče, često se u tom smislu nazivalo i naturalističkim (usp.

Adults Unable to Afford Dental Care in the Past Year 20.7% 22.3 % Adults Unable to Afford Medical Care in the Past Year 10.4% 11.8 % Adults Unable to Afford Mental Health Care

In particular, it will be employed to derive the quaternion-valued LMS (QLMS) algorithm and its sparse versions for adaptive beamforming for vector sensor arrays, and another one is