GithubHelp home page GithubHelp logo

isabella232 / android_adobe_extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adjust/android_adobe_extension

0.0 0.0 0.0 202 KB

Adjust Extension for Adobe Experience SDK

License: MIT License

Java 100.00%

android_adobe_extension's Introduction

Adjust Extension for Adobe Experience SDK

This is the Android Adobe Mobile Extension of Adjust™. You can read more about Adjust™ at adjust.com.

Table of contents

Quick start

Event tracking

Additional features

Quick start

Example app

There is an Android example app inside the example-app directory. You can open the Android project to see the example on how the Adjust Adobe Extension can be integrated.

Getting started

These are the minimum required steps to integrate the Adjust Extension in your Android app. We assume that you are using Android Studio for your Android development. The minimum supported Android API level for the Adjust Extension for Adobe Experience SDK integration is 14 (Ice Cream Sandwich).

Add the Extension to your project

If you are using Maven, add the following to your build.gradle file:

implementation 'com.adjust.adobeextension:adobeextension:1.0.1'
implementation 'com.adjust.sdk:adjust-android:4.27.0'
implementation 'com.android.installreferrer:installreferrer:2.2'

Add Google Play Services

Apps in the Google Play Store must use the Google Advertising ID to uniquely identify devices. To enable the Google Advertising ID for our SDK, you must integrate Google Play Services. If you haven't done this yet, please add dependency to the Google Play Services library by adding the following dependecy to your dependencies block of app's build.gradle file:

implementation 'com.google.android.gms:play-services-ads-identifier:17.0.0'

Note: The Adjust Extension is not tied to any specific version of the play-services-analytics part of the Google Play Services library. You can use the latest version of the library, or any other version you need.

Add permissions

The Adjust Extension requires the following permissions. Please add them to your AndroidManifest.xml file if they are not already present:

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

If you are not targeting the Google Play Store, you must also add the following permission:

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

Proguard settings

If you are using Proguard, add these lines to your Proguard file:

-keep class com.adjust.sdk.** { *; }
-keep class com.google.android.gms.common.ConnectionResult {
    int SUCCESS;
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    boolean isLimitAdTrackingEnabled();
}
-keep public class com.android.installreferrer.** { *; }

If you are not publishing your app in the Google Play Store, use the following package rules:

-keep class com.adjust.sdk.** { *; }

Install referrer

In order to correctly attribute an app install to its source, Adjust needs information about the install referrer. We can achieve this by using the Google Play Referrer API for apps on Google Play Store and by using the Huawei Referrer API for apps on Huawei Mobile Store.

Google Play Referrer API

In order to support the Google Play Referrer API in your app, please make sure that you have followed our chapter on adding the Extension to your project correctly and that you have following line added to your build.gradle file:

implementation 'com.android.installreferrer:installreferrer:2.1'

Please follow the directions for your Proguard settings carefully. Confirm that you have added all the rules mentioned in it, especially the one needed for this feature:

-keep public class com.android.installreferrer.** { *; }

Integrate the Adjust Extension into your app

First, we'll set up basic session tracking.

Basic setup

We recommend using a global Android Application class to register the Extension. If you don't have one in your app, follow these steps:

  • Create a class that extends the Application.
  • Open the AndroidManifest.xml file of your app and locate the <application> element.
  • Add the attribute android:name and set it to the name of your new application class.

In our example app, we use an Application class named MainApp. Therefore, we configure the manifest file as:

 <application
   android:name=".MainApp"
   <!-- ... -->
 </application>
  • In your Application class, find or create the onCreate method. Add the following code to register the Adjust Extension:
import com.adjust.adobeextension.AdjustAdobeExtension;
import com.adjust.adobeextension.AdjustAdobeExtensionConfig;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;


public class MainApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();

        // basic Adobe extension setup
        MobileCore.setApplication(this);
        MobileCore.setLogLevel(LoggingMode.VERBOSE);

        // register Adjust Adobe extension
        String environment = AdjustAdobeExtensionConfig.ENVIRONMENT_SANDBOX;
        AdjustAdobeExtensionConfig config = new AdjustAdobeExtensionConfig(environment);
        AdjustAdobeExtension.registerExtension(config);

        // start Adobe core
        MobileCore.start(new AdobeCallback () {
        @Override
        public void call(Object o) {
            MobileCore.configureWithAppID("your_adobe_app_id");
        }
    });
    }
}

Replace {your_adobe_app_id} with your app id from Adobe Launch.

Next, you must set the environment to either sandbox or production mode:

String environment = AdjustAdobeExtensionConfig.ENVIRONMENT_SANDBOX;
String environment = AdjustAdobeExtensionConfig.ENVIRONMENT_PRODUCTION;

Important: Set the value to AdjustAdobeExtensionConfig.ENVIRONMENT_SANDBOX if (and only if) you or someone else is testing your app. Make sure to set the environment to AdjustAdobeExtensionConfig.ENVIRONMENT_PRODUCTION before you publish the app. Set it back to AdjustAdobeExtensionConfig.ENVIRONMENT_SANDBOX if you start developing and testing it again.

We use this environment to distinguish between real traffic and test traffic from test devices. Keeping the environment updated according to your current status is very important!

Session tracking

Adjust SDK can track sessions in your app based on Activity lifecycle.

Attribution

The option to share attribution data with Adobe is in the Launch dashboard under the extensions configuration and is on by default. Adjust tracks the action name Adjust Campaign Data Received with the following attribution information from Adjust:

  • Adjust Network
  • Adjust Campaign
  • Adjust AdGroup
  • Adjust Creative

Adjust logging

You can increase or decrease the amount of logs that you see during testing by calling setLogLevel on Adobe Mobile Core instance with one of the following parameters:

MobileCore.setLogLevel(LogLevel.VERBOSE); // enable all logs
MobileCore.setLogLevel(LogLevel.DEBUG); // disable verbose logs
MobileCore.setLogLevel(LogLevel.WARNING); // disable debug logs
MobileCore.setLogLevel(LogLevel.ERROR); // disable warning logs

Build your app

Build and run your Android app. In your LogCat viewer, set the filter tag:Adjust to hide all other logs. After your app has launched you should see the following Adjust log: Install tracked.

Event tracking

Track event

You can use Adobe MobileCore.trackAction API for event tracking. Suppose you want to track every tap on a button. To do so, you'll create a new event token in your dashboard. Let's say that the event token is abc123. In your button's onClick method, add the following lines to track the click:

String action = "Track button click";
Map<String, String> contextData= new HashMap<String, String>();
contextData.put("adj.eventToken", "abc123");

MobileCore.trackAction(action, contextData);

Note: The key used for eventToken is prefixed with adj.

Track revenue

If your users can generate revenue by tapping on advertisements or making in-app purchases, you can track those revenues too with events. Let's say a tap is worth one Euro cent. You can track the revenue event like this:

String action = "Track revenue event";
Map<String, String> contextData= new HashMap<String, String>();
contextData.put("adj.eventToken", "abc123");
contextData.put("adj.revenue", "0.01");
contextData.put("adj.currency", "EUR");

Note: The key used are prefixed with adj.

Additional features

Once you have integrated the Adjust Extension for Adobe Experience SDK into your project, you can take advantage of the following features:

Attribution callback

You can register a listener to be notified of tracker attribution changes. Due to the different sources we consider for attribution, we cannot provide this information synchronously.

Please see our attribution data policies for more information.

With the extension config instance, add the attribution callback before you start the SDK:

AdjustAdobeExtensionConfig config = new AdjustAdobeExtensionConfig(environment);

config.setOnAttributionChangedListener(new OnAttributionChangedListener() {
    @Override
    public void onAttributionChanged(AdjustAttribution attribution) {}
});

AdjustAdobeExtension.registerExtension(config);

The listener function is called after the SDK receives the final attribution data. Within the listener function, you'll have access to the attribution parameter.

Deferred deep linking callback

The Adjust SDK opens the deferred deep link by default. There is no extra configuration needed. But if you wish to control whether the Adjust SDK will open the deferred deep link or not, you can do it with a callback method in the config object.

With the extension config instance, add the deferred deep linking callback before you start the SDK:

AdjustAdobeExtensionConfig config = new AdjustAdobeExtensionConfig(environment);

config.setOnDeeplinkResponseListener(new OnDeeplinkResponseListener() {
    @Override
    public boolean launchReceivedDeeplink(Uri deeplink) {
        // ...
        if (shouldAdjustSdkLaunchTheDeeplink(deeplink)) {
            return true;
        } else {
            return false;
        }
    }
});

AdjustAdobeExtension.registerExtension(config);

After the Adjust SDK receives the deep link information from our backend, the SDK will deliver you its content via the listener and expect the boolean return value from you. This return value represents your decision on whether or not the Adjust SDK should launch the activity to which you have assigned the scheme name from the deeplink.

android_adobe_extension's People

Contributors

danielsatriano avatar nonelse avatar shashanksu avatar uerceg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.