public final class ActionTracker
extends com.jetlore.sdk.common.JetloreCommon
ActionTracker needs permission to access the Internet. Add the following to AndroidManifest.xml (inside <manifest>
element):
<uses-permission android:name="android.permission.INTERNET"/>
To initialize ActionTracker you need to provide a Jetlore URL and Jetlore API access token in AndroidManifest.xml:
<string name="jetlore_api_url">https://api.jetlore.com</string>
to strings.xml<meta-data android:name="com.jetlore.sdk.API_URL" android:value="@string/jetlore_api_url"/>
to AndroidManifest.xml (inside <application>
element)<string name="jetlore_access_token">YOUR_JETLORE_API_ACCESS_TOKEN</string>
to strings.xml<meta-data android:name="com.jetlore.sdk.AccessToken" android:value="@string/jetlore_access_token"/>
to AndroidManifest.xml (inside <application>
element)configure(String, String, String)
configure(userId, apiUrl, accessToken, String clientHash)
You can create an ActionTracker instance in your activity onCreate method like this:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
actionTracker = new ActionTracker(this);
}
Before using it you need to initialize ActionTracker with a user id: (if you already not initialize it with configure(String, String, String)
)
String userId = ...;
actionTracker.configure(userId);
The user ID has to be the same ID you use inside of your email template.
Methods trackView(java.lang.String, java.lang.String)
and trackPurchase(java.util.Map<java.lang.String, java.lang.Integer>)
are legacy methods. Please use new API trackView(ProductContext, String, ActionContext)
trackPurchases(List, ActionContext)
etc
trackView(java.lang.String, java.lang.String)
and trackPurchase(java.util.Map<java.lang.String, java.lang.Integer>)
make asynchronous HTTP calls to Jetlore API, do NOT block and are safe to use from the UI thread.
Modifier and Type | Field and Description |
---|---|
static ActionContext |
EMPTY_CONTEXT
Empty action context
|
static java.lang.String |
NO_CAMPAIGN
Constant value to use with
trackView(java.lang.String, java.lang.String) method if product view doesn't come from email click (deep linking) |
Constructor and Description |
---|
ActionTracker(android.content.Context context)
Creates a new ActionTracker
|
Modifier and Type | Method and Description |
---|---|
void |
configure(java.lang.String userId,
java.lang.String apiUrl,
java.lang.String accessToken)
Re-Initialize ActionTracker with apiUrl, accessToken and clientHash
Please use
JetloreCommon.configure(String) to change or initialize userId |
protected void |
readAdditionalParameters(android.os.Bundle bundle) |
void |
trackAddToCartProduct(ProductContext product,
ActionContext actionContext)
Sends information about Add to Cart to Jetlore API
|
void |
trackAddToCartProducts(java.util.List<ProductContext> products,
ActionContext actionContext)
Sends information about Add to Cart to Jetlore API
|
void |
trackGenericAction(java.lang.String actionName,
ActionContext actionContext)
Special method that is absolutely generic Jetlore API.
|
void |
trackPurchase(java.util.Map<java.lang.String,java.lang.Integer> cart)
Deprecated.
use
trackPurchases(List, ActionContext) instead. |
void |
trackPurchase(ProductContext product,
ActionContext actionContext)
Sends information about product purchase to Jetlore API
|
void |
trackPurchases(java.util.List<ProductContext> products,
ActionContext actionContext)
Sends information about product purchases to Jetlore API
|
void |
trackRemoveFromCartProduct(ProductContext product,
ActionContext actionContext)
Sends information about Remove from Cart to Jetlore API
|
void |
trackRemoveFromCartProducts(java.util.List<ProductContext> products,
ActionContext actionContext)
Sends information about Remove from Cart to Jetlore API
|
void |
trackSearchQuery(java.lang.String text,
ActionContext actionContext)
Sends information about search queries to Jetlore API
|
void |
trackView(ProductContext product,
ActionContext actionContext)
Sends information about product view to Jetlore API
|
void |
trackView(ProductContext product,
java.lang.String campaignId,
ActionContext actionContext)
Sends information about product view to Jetlore API
|
void |
trackView(java.lang.String productId,
java.lang.String campaignId)
Deprecated.
use
trackView(ProductContext, String, ActionContext) instead. |
public static final java.lang.String NO_CAMPAIGN
trackView(java.lang.String, java.lang.String)
method if product view doesn't come from email click (deep linking)public static final ActionContext EMPTY_CONTEXT
public ActionTracker(android.content.Context context)
Uses provided Context
to get Jetlore API access key
from AndroidManifest.xml and to get SharedPreferences
to persist cookies
context
- tracking contextprotected void readAdditionalParameters(android.os.Bundle bundle)
readAdditionalParameters
in class com.jetlore.sdk.common.JetloreCommon
public void configure(java.lang.String userId, java.lang.String apiUrl, java.lang.String accessToken)
JetloreCommon.configure(String)
to change or initialize userId
Use JetloreCommon.NO_USER
as userId if user id is unknown at the moment.
Make sure to call configure(java.lang.String, java.lang.String, java.lang.String)
again once user id is known.
userId
- tracking user idapiUrl
- Jetlore API endpoint URLaccessToken
- Client accessTokencom.jetlore.sdk.common.InvalidUseException
- if userId is null or empty
if apiUrl is null or empty
if accessToken is null or empty@Deprecated public void trackView(java.lang.String productId, java.lang.String campaignId)
trackView(ProductContext, String, ActionContext)
instead.This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
productId
- Viewed product IDcampaignId
- Jetlore campaign id. Use NO_CAMPAIGN
if product view doesn't come from email click (deep linking).com.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if productId is null or empty;@Deprecated public void trackPurchase(java.util.Map<java.lang.String,java.lang.Integer> cart)
trackPurchases(List, ActionContext)
instead.This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
cart
- Purchased items map, with product id as a key and purchase amount as a valuecom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if productId is null or empty;
if count id zero or negative;public void trackPurchases(java.util.List<ProductContext> products, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
products
- list of ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if productId is null or empty;
if count id zero or negative;public void trackPurchase(ProductContext product, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
product
- ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if productId is null or empty;
if count id zero or negative;public void trackView(ProductContext product, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
product
- ProductContext
to sentactionContext
- ActionContext
action context objectpublic void trackView(ProductContext product, java.lang.String campaignId, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
product
- ProductContext
to sentcampaignId
- Jetlore campaign id.actionContext
- ActionContext
action context object
*com.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if productId is null or empty;
if count id zero or negative;public void trackAddToCartProducts(java.util.List<ProductContext> products, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
products
- list of ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if productId is null or empty;
if count id zero or negative;public void trackAddToCartProduct(ProductContext product, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
product
- ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if productId is null or empty;
if count id zero or negative;public void trackRemoveFromCartProducts(java.util.List<ProductContext> products, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
products
- list of ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if productId is null or empty;
if count id zero or negative;public void trackRemoveFromCartProduct(ProductContext product, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
product
- ProductContext
to sentactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if productId is null or empty;
if count id zero or negative;public void trackSearchQuery(java.lang.String text, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
text
- search query textactionContext
- ActionContext
action context objectcom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)public void trackGenericAction(java.lang.String actionName, ActionContext actionContext)
This method makes an asynchronous HTTP call to Jetlore API, does NOT block and is safe to use from the UI thread
actionName
- name of action. Sting that contains identifier of action. To obtain currently supported values please contact JetloreactionContext
- ActionContext
action context object. Please use ActionContext.addCustomParameter(String, String)
to add parameterscom.jetlore.sdk.common.InvalidUseException
- if name of custom parameter ActionContext.addCustomParameter(String, String)
intersects with internally used
if tracker is not configured (user id is not initialized JetloreCommon.configure(String)
)
if action is null or empty