Android native
Installation
Add the JitPack repository to your root build.gradle file:
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Add the dependency to your module’s build.gradle:
dependencies {
implementation 'com.github.EulerianTechnologies:eanalytics-android:1.9.0'
}
Add the required permissions to your AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
To track installs from Google Play, also add this receiver:
<receiver
android:name="com.eulerian.android.sdk.InstallReferrerReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Initialisation
Initialise the SDK in your Application.onCreate(). First declare your Application subclass in the manifest.
<!-- AndroidManifest.xml -->
<application android:name=".DemoApp">
public class DemoApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// Replace "example.demo.com" with your tracking subdomain
EAnalytics.init(this, "example.demo.com", false);
}
}
The third parameter turns debug logs on (
true) or off (false).
Traffic attribution in Eulerian: unlike web tracking, where the URL identifies the site, a native app has no URL. The SDK automatically uses the app’s package name (e.g.
com.mycompany.myapp) as the internal URL sent to Eulerian (theea-appnameandurlparameters). Eulerian relies on the tracking subdomain passed toinit()to attribute the traffic to the right site in its interface.
If several apps share the same tracking subdomain, use the
fromparameter in the tags to tell them apart.
Tag types
path(the page name) is mandatory on every tag. It is never picked up automatically, unlike on the web where the URL identifies the page. Use a hierarchical convention with|as the separator, for example"home|accueil","catalogue|chaussures|homme","tunnel|paiement|confirmation". The value is up to you, but it must be stable and meaningful for reporting.
Generic method
set(String key, String value): available on every tag, it lets you add any custom parameter that the dedicated methods do not cover. Example:.set("abonnement", "mensuel").
Generic page · EAProperties
Use it on every page that is not a product, cart, order or quote page (including the homepage and the funnel steps between the cart and the order confirmation). It reports site-centric traffic, page views, visits and natural sources.
Methods:
Builder(String path), page name (mandatory)setUID(String uid), internal ID of the logged-in user; consolidates cross-device history and lets a click be reconciled with a downloadsetEmail(String email), the user’s emailsetProfile(String profile), the user’s profile (e.g.visitor,buyer,looker)setPageGroup(String group), page group for reportingset(String key, String value), free custom parametersetCFlag(SiteCentricCFlag flag), attaches one or more context flags to the tag (see Context Flag )
Example:
EAProperties genericTag = new EAProperties.Builder("home|accueil")
.setPageGroup("MY-PAGEGROUP")
.setUID("123asd")
.setEmail("test@test.fr")
.setProfile("visitor")
.set("KEY-CUSTOM-PARAM", "VALUE")
.build();
EAnalytics.getInstance().track(genericTag);
Product page · EAProducts (1 product)
Tracks product page views and feeds the “Product acquisition & performance” report. A tag counts as a product page when it contains exactly one product reference and none of the parameters scart, estimate, ref, amount.
Methods:
Builder(String path), page name (mandatory)setUID(String uid), internal ID of the logged-in usersetEmail(String email), the user’s emailsetProfile(String profile), the user’s profilesetPageGroup(String group), page group for reportingaddProduct(Product product), adds the product reference (mandatory)set(String key, String value), free custom parameter
Building a Product:
Product.Builder(String ref), product reference (mandatory)setName(String name), readable product name for reportingsetGroup(String group), product groupsetParams(Params params), product categories (e.g.prdparam-category,prdparam-brand)
Building a Params:
addParam(String key, String value), adds a product category; the key is the suffix afterprdparam-
Example:
Params productParams = new Params.Builder()
.addParam("category", "clothes") // prdparam-category
.addParam("brand", "nike") // prdparam-brand
.build();
Product product1 = new Product.Builder("ref-product")
.setName("name-product")
.setGroup("group-product")
.setParams(productParams)
.build();
EAProducts productPage = new EAProducts.Builder("produit|fiche")
.setPageGroup("my-pagegroup")
.setUID("123asd")
.setEmail("test@test.fr")
.setProfile("looker")
.addProduct(product1)
.build();
EAnalytics.getInstance().track(productPage);
Category page · EAProducts (N products)
Sends the first N product references shown on a results or category page to partners for retargeting. A tag counts as a category page when it contains more than one product reference and none of the parameters scart, estimate, ref, amount.
Methods:
Builder(String path), page name (mandatory)setUID(String uid), internal ID of the logged-in usersetEmail(String email), the user’s emailsetPageGroup(String group), page group for reportingaddProduct(Product product), adds a product reference; repeat for each product shownset(String key, String value), free custom parameter
Example:
Product product1 = new Product.Builder("ref-product1").build();
Product product2 = new Product.Builder("ref-product2").build();
Product product3 = new Product.Builder("ref-product3").build();
EAProducts resultPage = new EAProducts.Builder("categorie|chaussures")
.setPageGroup("my-pagegroup")
.setUID("123asd")
.setEmail("test@test.fr")
.addProduct(product1)
.addProduct(product2)
.addProduct(product3)
.build();
EAnalytics.getInstance().track(resultPage);
Search engine page · EASearch
Tracks internal search engine queries, the number of results and custom search parameters. A tag counts as a search engine page when it contains isearchengine. Not exclusive: it can be combined with a product reference on the same tag.
Methods:
Builder(String path, String engineName), page name + search engine name (mandatory)setResults(int results), number of results returned by the searchsetParams(Params params), extra search parameters (key/value pairs matchingisearchkey/isearchdata)setUID(String uid), internal ID of the logged-in userset(String key, String value), free custom parameter
Example:
Params searchParams = new Params.Builder()
.addParam("motcle", "veste")
.addParam("montant_min", "100.00")
.addParam("montant_max", "400.00")
.build();
EASearch searchPage = new EASearch.Builder("moteur_interne|veste", "moteur_interne")
.setUID("34678")
.setResults(150)
.setParams(searchParams)
.build();
EAnalytics.getInstance().track(searchPage);
404 error page · EAProperties
Flag a 404 error page by adding set("error", "1") to any tag. It feeds the “Error pages” report.
Methods:
Builder(String path), page name (mandatory)set("error", "1"), flags the page as a 404 error (mandatory)
Example:
EAProperties errorTag = new EAProperties.Builder("erreur|404")
.set("error", "1")
.build();
EAnalytics.getInstance().track(errorTag);
Quote page · EAEstimate
Tracks quotes and the products attached to them. A tag counts as a quote page when it contains the ref and estimate parameters, both set automatically by the builder. Quotes are deduplicated by reference: a second call with the same reference is ignored.
Methods:
Builder(String path, String ref), page name + unique quote reference (mandatory)setAmount(double amount), total quote amount including tax (decimals separated by a point)setType(String type), quote type according to your own taxonomysetCurrency(String currency), currency, if different from the one configured in the interfaceaddProduct(Product product, double amount, int quantity), adds a product with its unit amount and quantity.setUID(String uid), internal ID of the logged-in usersetEmail(String email), the user’s emailset(String key, String value), free custom parameter
Example:
Product product1 = new Product.Builder("505").build();
EAEstimate estimatePage = new EAEstimate.Builder("credit|devis", "C4536567")
.setPageGroup("my-pagegroup")
.setUID("123asd")
.setEmail("test@test.fr")
.setAmount(5000.00)
.setType("credit_48mois")
.set("custom-param-KEY", "custom-param-value")
.addProduct(product1, 5000.00, 1)
.build();
EAnalytics.getInstance().track(estimatePage);
Cart page · EACart
Tracks started carts and makes it possible to calculate conversion and abandonment rates. A tag counts as a cart page when it contains the scart parameter, set automatically by the builder. A cart lives for a rolling 30 minutes.
Methods:
Builder(String path), page name (mandatory)setCartCumul(boolean cumul),false: the tag’s products represent the whole cart (snapshot);true: products accumulate with each successive calladdProduct(Product product, double amount, int quantity), adds a product with its unit amount and quantitysetUID(String uid), internal ID of the logged-in usersetEmail(String email), the user’s emailsetProfile(String profile), the user’s profilesetPageGroup(String group), page group for reportingset(String key, String value), free custom parameter
Example:
Params productParams = new Params.Builder()
.addParam("category", "T-Shirt") // prdparam-category
.addParam("brand", "Nike") // prdparam-brand
.build();
Product product1 = new Product.Builder("product-123")
.setName("product-name")
.setParams(productParams)
.build();
EACart cartPage = new EACart.Builder("panier")
.setPageGroup("my-page-group")
.setUID("123asd")
.setEmail("test@test.fr")
.setProfile("shopper")
.setCartCumul(false)
.addProduct(product1, 50.30, 2)
.build();
EAnalytics.getInstance().track(cartPage);
Order page · EAOrder
Tracks conversions and ROI. A tag counts as an order when it contains ref and amount without scart or estimate. Orders are deduplicated by reference. Implement this tag as early as possible in the payment funnel, so you do not miss it if the user never comes back to the site after the payment platform.
Methods:
Builder(String path, String ref), page name + unique order reference (mandatory)setAmount(double amount), total amount including tax, excluding shipping (mandatory)setPayment(String payment), payment method used (e.g.credit card,paypal)setType(String type), sale type according to your own taxonomysetCurrency(String currency), currency, if different from the one configured in the interfacesetNewCustomer(boolean newCustomer),true: new buyer;false: returning customersetEstimateRef(String ref), reference of the quote linked to this order (optional)addProduct(Product product, double amount, int quantity), adds a product with its unit amount and quantitysetUID(String uid), internal ID of the logged-in usersetEmail(String email), the user’s emailsetProfile(String profile), the user’s profileset(String key, String value), free custom parameter
Example:
Params productParams = new Params.Builder()
.addParam("category", "T-Shirt") // prdparam-category
.addParam("brand", "Nike") // prdparam-brand
.build();
Product product1 = new Product.Builder("product-123")
.setName("product-name")
.setParams(productParams)
.build();
EAOrder orderPage = new EAOrder.Builder("tunnel|confirmation", "F654335671")
.setPageGroup("my-pagegroup")
.setUID("123asd")
.setEmail("test@test.fr")
.setProfile("buyer")
.setNewCustomer(true)
.setAmount(50.30)
.setType("online")
.setPayment("credit card")
.setCurrency("EUR")
.setEstimateRef("asd123qwe")
.set("custom-param-key", "custom-param-value")
.addProduct(product1, 25.15, 2)
.build();
EAnalytics.getInstance().track(orderPage);
Merchandising tracking · EATpView / EATpClick
Tracks impressions and clicks on merchandising blocks (recommendation lists, banners and so on). Sent as GET to /tpview/ and /tpclick/, unlike the other tags, which are sent as POST. Supports the same offline retry mechanism as the rest of the SDK.
Methods EATpView (impression):
Builder(String path), reference page (mandatory)setSiteName(String name), name of the merchant sitesetCampaign(String campaign), campaign namesetPlacement(String placement), placement of the block on the pageaddProduct(String ref, Integer position), product reference and its position in the block; repeat for each product shownsetUrl(String url), context URLsetPublisher(String publisher), publisher (optional)setMedia(String media), media type (optional)setCategory(String category), block category (optional)
Methods EATpClick (click):
Builder(String path), reference page (mandatory)setSiteName(String name), name of the merchant sitesetCampaign(String campaign), campaign namesetPlacement(String placement), placement of the block on the pagesetProduct(String ref, int position), reference and position of the clicked product (mandatory)setProduct(String ref, int position, Integer totalProducts), variant with the total number of products in the blocksetUrl(String url), context URLsetPublisher(String publisher), publisher (optional)setMedia(String media), media type (optional)setCategory(String category), block category (optional)
Example:
// Impression on a merchandising block
EATpView view = new EATpView.Builder("homepage")
.setSiteName("my-site")
.setCampaign("summer_sale")
.setPlacement("banner_top")
.addProduct("PROD_001", 0)
.addProduct("PROD_002", 1)
.setUrl("https://www.example.com")
.build();
EAnalytics.getInstance().track(view);
// Click on a product in the block
EATpClick click = new EATpClick.Builder("homepage")
.setSiteName("my-site")
.setCampaign("summer_sale")
.setPlacement("banner_top")
.setProduct("PROD_001", 0)
.setUrl("https://www.example.com")
.build();
EAnalytics.getInstance().track(click);
Context Flag (CFLAG) · SiteCentricCFlag
Attach one or more context flags to any tag to enrich your reports with contextual dimensions. A tag accepts at most 10 context flag values, across all dimensions.
Methods SiteCentricCFlag:
Builder(), constructorset(String key, String... values), defines a contextual dimension with one or more values
Added to a tag with:
setCFlag(SiteCentricCFlag flag), available on every tag type
Example:
import com.eulerian.android.sdk.SiteCentricCFlag;
EAProperties genericTag = new EAProperties.Builder("home|accueil")
.setUID("UID")
.setEmail("email@test.fr")
.setProfile("profile")
.setCFlag(new SiteCentricCFlag.Builder()
.set("categorie_1", "rolandgarros", "wimbledon")
.set("categorie_2", "tennis")
.set("categorie_3", "usopen")
.build())
.build();
EAnalytics.getInstance().track(genericTag);
WebView tracking
For hybrid apps that open a WebView, pass the SDK’s internal identifier in the opening URL so that tracking carries on between the native app and the web session. Also add the edev parameter to flag the traffic as native (mandatory for tracking in-app campaigns and push notifications).
String euidl = EAnalytics.getEuidl();
// Build the WebView URL:
// https://www.example.com/android-landing?ea-euidl-bypass=<euidl>&edev=AppNativeAndroidphone
Accepted values for edev:
| Value | Device |
|---|---|
AppNativeAndroidphone | Android phone |
AppNativeAndroidtablet | Android tablet |
AppNativeIOSphone | iPhone |
AppNativeIOStablet | iPad |
ea-euidl-bypassmust be present on every URL change in the WebView, otherwise the link between app and web browsing is lost.
App metrics
Downloads and updates are tracked with the three parameters below. The first two are collected automatically by the SDK on every hit: there is nothing for you to do. The third, ea-appinstalled, is the only one you pass by hand, and only during a migration.
| Parameter | Value | Description |
|---|---|---|
ea-appname | App name | App identifier (must never change), collected automatically by the SDK |
ea-appversion | Version string | Current version, collected automatically by the SDK |
ea-appinstalled | 1 | To pass manually if the app existed before the Eulerian integration |
System logic:
- The Download metric is incremented when
ea-appnameis seen for the first time for this user (withoutea-appinstalled). - The Update metric is incremented when
ea-appnameis unchanged butea-appversionhas a new value compared with the last launch.
Migration (app that existed before Eulerian): pass ea-appinstalled with the generic setter, on the first tag sent at launch.
EAProperties migrationTag = new EAProperties.Builder("home|accueil")
.set("ea-appinstalled", "1")
.build();
EAnalytics.getInstance().track(migrationTag);
Consent (GDPR)
The two modes below are mutually exclusive. Choose one, and never use both in the same app.
Mode 1 · TCF v2 (gdpr_consent)
Pass the TCString generated by your CMP once per visitor, at the moment the user opts in or out.
EAProperties consentTag = new EAProperties.Builder("univers|rubrique|page")
.setUID("5434742")
.set("abonnement", "mensuel")
.set("gdpr_consent", "EADURF214345") // your TCString
.build();
EAnalytics.getInstance().track(consentTag);
Mode 2 · Categories (pmcat)
Pass the Eulerian IDs of the refused categories, separated by -. Send - on its own if the user accepts every category.
EAProperties consentTag = new EAProperties.Builder("univers|rubrique|page")
.setUID("5434742")
.set("abonnement", "mensuel")
.set("pmcat", "1-10") // IDs of the refused categories
.build();
EAnalytics.getInstance().track(consentTag);
Example category mapping:
| Category | Eulerian ID |
|---|---|
| analytics | 1 |
| advertising | 10 |
| functional | 19 |
Example: the user refuses analytics and advertising, so pmcat is 1-10.
General opt-out URL
Provide this URL on your “Privacy / GDPR” page or in your CMP for a full, unconditional opt-out:
https://<votre-domaine-de-collecte>/optout.html?url=<votre-domaine>
Summary
| TCF v2 mode | Categories mode | |
|---|---|---|
| Parameter | gdpr_consent | pmcat |
| When | At opt-in/out | At opt-in/out |
| Content | TCString | Refused IDs or - |
| CMP compatibility | TCF v2 CMP | In-house / non-TCF CMP |
Dependencies
The following dependencies are included automatically with the SDK:
com.google.android.gms:play-services-ads-identifier:17.0.0
com.android.installreferrer:installreferrer:2.2