public class

Apptimize

extends Object
java.lang.Object
   ↳ com.apptimize.Apptimize

Summary

Nested Classes
enum Apptimize.IsFirstTestRun An enum that indicates if this is the first time that a test has been run. 
interface Apptimize.OnApptimizeInitializedListener  
interface Apptimize.OnExperimentRunListener This interface is deprecated. Use Apptimize.OnTestRunListener instead.  
interface Apptimize.OnExperimentsProcessedListener Interface definition for a callback to be invoked when an Apptimize A/B experiment configuration is recalculated. 
interface Apptimize.OnTestEnrollmentChangedListener Interface definition for callbacks to be invoked when an Apptimize A/B experiment enrollment has changed. 
interface Apptimize.OnTestRunListener Interface definition for a callback to be invoked when an Apptimize A/B test is run. 
enum Apptimize.UnenrollmentReason This enumerated type is used to indicate why the user has been unenrolled from a given experiment. 
Public Methods
static void addOnExperimentsProcessedListener(Apptimize.OnExperimentsProcessedListener listener)
Add a callback to be invoked when an Apptimize configuration is recalculated.
static void addToMetric(String metricName, double value)
This method is deprecated. Use track(String, double) instead.
static void clearAllForcedVariants()
Stop forcing variants.
static void clearForcedVariant(Long variantId)
Stop forcing the variant with the given Id.
static void clearUserAttribute(String attributeName)
Erase a user attribute from memory so it's no longer used for targeting/filtering/segmenting.
static void disable()
Disables Apptimize.
static double doubleForTest(String varName, double defaultValue, ApptimizeOptions options)

Get the double associated with an Apptimize variable.

static double doubleForTest(String varName, double defaultValue)

Get the double associated with an Apptimize variable.

static void event(String eventName, double value)
This method is deprecated. Use track(String, double) instead.
static void event(String eventName)
This method is deprecated. Use track(String) instead.
static void forceVariant(Long variantId)

Force the variant with the given ID to be enabled.

static String getApptimizeAnonUserId()

Get the current Apptimize-created anonymous user ID

This anonymous user ID will be used if-and-only-if the customer-specified user ID is null.

static String getCustomerUserId()

Get the current customer-specified userId

User IDs are arbitrary strings.

static String getExperimentString(String varName, String defaultValue)
This method is deprecated. Use stringForTest(String, String) instead.
static Map<String, ApptimizeInstantUpdateOrWinnerInfo> getInstantUpdateOrWinnerInfo()

Returns information about all winning Apptimize A/B tests and Instant Updates that the device is using.

static Map<String, ApptimizeInstantUpdateOrWinnerInfo> getInstantUpdateOrWinnerInfo(ApptimizeOptions options)

Returns information about all winning Apptimize A/B tests and Instant Updates that the device is using.

static String getPilotTargetingId()
static Map<String, ApptimizeTestInfo> getTestInfo(ApptimizeOptions options)

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in.

static Map<String, ApptimizeTestInfo> getTestInfo()

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in.

static Boolean getUserAttributeBoolean(String attributeName)
Get the value of a user attribute boolean.
static Double getUserAttributeDouble(String attributeName)
Get the value of a user attribute double.
static Integer getUserAttributeInteger(String attributeName)
Get the value of a user attribute integer.
static String getUserAttributeString(String attributeName)
Get the value of a user attribute string.
static String getUserId()
This method is deprecated. Use getApptimizeAnonUserId() instead.
static Map<Long, Map<String, Object>> getVariants(ApptimizeOptions options)

return information about all variants launched.

static Map<Long, Map<String, Object>> getVariants()

return information about all variants launched.

static void goalAchieved(String goalName)
Inform Apptimize a metric was achieved.
static int integerForTest(String varName, int defaultValue)

Get the int associated with an Apptimize variable.

static int integerForTest(String varName, int defaultValue, ApptimizeOptions options)

Get the int associated with an Apptimize variable.

static boolean isFeatureFlagOn(String name)
static boolean isFeatureFlagOn(String name, ApptimizeOptions options)
static void metricAchieved(String metricName)
Inform Apptimize a metric was achieved.
static void removeOnExperimentsProcessedListener(Apptimize.OnExperimentsProcessedListener listener)
Remove an observer to be invoked when an Apptimize configuration is recalculated.
static void reset(boolean setupAgain)
static void reset()
Simulates a fresh install of Apptimize.
static void runExperiment(String experimentName, ApptimizeExperiment experiment)
Executes an experiment.
static void runTest(String testName, ApptimizeTest test, ApptimizeOptions options)
Executes a code block test.
static void runTest(String testName, ApptimizeTest test)
Executes a code block test.
static void setActiveCodeBlockForExperiment(String experimentName, String variationMethodName)
Set the active code block for a specific experiment
static <T> void setActiveValueForDynamicVariable(ApptimizeVar<T> dynVar, T value)
Set the active value for a dynamic variable
static void setCustomerUserId(String customerUserId)

Set the current customer-specified user ID

User IDs are arbitrary strings, except that they cannot be the empty string "".

static void setMetric(String metricName, double value)
This method is deprecated. Use track(String, double) instead.
static void setOffline(boolean offline)

Set whether Apptimize should be in offline mode.

static void setOnApptimizeInitializedListener(Apptimize.OnApptimizeInitializedListener listener)
Register a callback to be invoked when Apptimize has completed setup and tests are available to be run.
static void setOnExperimentRunListener(Apptimize.OnExperimentRunListener listener)
This method is deprecated. Use setOnTestRunListener(OnTestRunListener) instead.
static void setOnTestEnrollmentChangedListener(Apptimize.OnTestEnrollmentChangedListener listener)
Register a callback to be invoked when an Apptimize A/B test enrollment has changed.
static void setOnTestRunListener(Apptimize.OnTestRunListener listener)
Register a callback to be invoked when an Apptimize A/B test is run.
static void setPilotTargetingId(String id)
static void setTestmodeActive(boolean mode)
Activate the Apptimize SDK test mode (used for unit testing)
static void setUserAttribute(String attributeName, int number)
Set a user attribute to be used in targeting/filtering/segmenting.
static void setUserAttribute(String attributeName, String string)
Set a user attribute to be used in targeting/filtering/segmenting.
static void setUserAttribute(String attributeName, boolean value)
Set a user attribute to be used in targeting/filtering/segmenting.
static void setUserAttribute(String attributeName, double number)
Set a user attribute to be used in targeting/filtering/segmenting.
static void setup(Context context, String appKey)
Initializes Apptimize with the default options.
static void setup(Context context, String appKey, ApptimizeOptions options)
Initializes Apptimize with the given options.
static String stringForTest(String varName, String defaultValue, ApptimizeOptions options)

Get the String associated with an Apptimize variable.

static String stringForTest(String varName, String defaultValue)

Get the String associated with an Apptimize variable.

static void track(String eventName)

Inform Apptimize that an event occurred.

static void track(String eventName, double value)

Inform Apptimize that an event occurred.

[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static void addOnExperimentsProcessedListener (Apptimize.OnExperimentsProcessedListener listener)

Add a callback to be invoked when an Apptimize configuration is recalculated. The enrolled experiments may or may not have changed. The dynamic variable values may or may not have changed. Feature flag values may or may not have changed. This happens at various times:

  • new information from server
  • device properties or custom attributes changed
  • and a few other cases

Parameters
listener The Apptimize.OnExperimentsProcessedListener that will be invoked when an Apptimize configuration is recalculated.

public static void addToMetric (String metricName, double value)

This method is deprecated.
Use track(String, double) instead.

Inform Apptimize that a numeric metric was achieved. A numeric metric is a noteworthy event associated with a numeric value that you wish to track. Call this whenever a numeric metric has been achieved, and this data will then be displayed in your results at apptimize.com.

For example, if the event you're interested in is a purchase event, you could call this method when a purchase is made and provide the price as the value. Then when viewing your results at apptimize.com you would be able to see the sum of the purchase prices.

Parameters
metricName The metric's name.
value The numeric value associated with this metric event.

public static void clearAllForcedVariants ()

Stop forcing variants. Normal allocation will resume.

public static void clearForcedVariant (Long variantId)

Stop forcing the variant with the given Id. If this is the only forced variant, normal allocation will resume.

Parameters
variantId The variantId to stop forcing.

public static void clearUserAttribute (String attributeName)

Erase a user attribute from memory so it's no longer used for targeting/filtering/segmenting. You may call this before or after the Apptimize.setup() call. Attributes will be uploaded with your data so you can filter and segment on them in the Apptimize results browser. You can also use them to target users via the Apptimize frontend. If you want to do targeting of users based on these attributes, you should ideally set your attributes before calling Apptimize.setup().

Parameters
attributeName The attribute's name/key.

public static void disable ()

Disables Apptimize. This will prevent Apptimize from further receiving or sending data, until the Application is closed/destroyed, restarted, and the setup(android.content.Context, String) method is called. If setup(android.content.Context, String) method has not been called yet, this disable method does nothing. Note that this disable method is only activated the moment it is called. Any events after setup(android.content.Context, String) is called, and prior to this disable method is called, will still be tracked.

public static double doubleForTest (String varName, double defaultValue, ApptimizeOptions options)

Get the double associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createDouble(String, Double) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

Options can be configured using the input ApptimizeOptions.

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
options Options for configuring this method. See ApptimizeOptions
Returns
  • The double value this device should use for this A/B test variable.

public static double doubleForTest (String varName, double defaultValue)

Get the double associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createDouble(String, Double) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

This method's options can be configured by instead calling doubleForTest(String, double, ApptimizeOptions)

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
Returns
  • The double value this device should use for this A/B test variable.

public static void event (String eventName, double value)

This method is deprecated.
Use track(String, double) instead.

Inform Apptimize that an event occurred. For noteworthy events that you wish to track, you should call this method each time the event occurs. This data will then be displayed in your results at apptimize.com. Examples of events you could track include: purchases being made, login events, and Facebook shares.

If there is a numeric value associated with this event that you'd like to track and view at apptimize.com, provide it as the input parameter value. For example, if the event is a purchase, the value might be the price. If there is no such value, use track(String) instead.

Parameters
eventName The event's name.
value The numeric value associated with this event.

public static void event (String eventName)

This method is deprecated.
Use track(String) instead.

Inform Apptimize that an event occurred. For noteworthy events that you wish to track, you should call this method each time the event occurs. This data will then be displayed in your results at apptimize.com. Examples of events you could track include: purchases being made, login events, and Facebook shares.

If there is a numeric value associated with this event that you'd like to track and view at apptimize.com, use track(String, double) instead.

Parameters
eventName The event's name.

public static void forceVariant (Long variantId)

Force the variant with the given ID to be enabled.

All variants forced using this method will be treated as though they underwent experiment selection, and will be reflected on your results dashboard. Forced variants are persistent across application launches and will not be reset except by calls to clearForcedVariant or clearAllForcedVariants.

If called multiple times, all variants supplied to invocations of this method will be turned on.

setForceVariantsShowWinnersAndInstantUpdates(boolean) determines whether winners and instant-updates will be shown. By default, this setting is off, so change your call to Apptimize.setup to turn it on as needed. Note that the "Advanced Verify" feature on the dashboard will only work when winners and instant-updates are being shown, because "Advanced Verify" works by sending an instant update to the paired device.

Parameters
variantId The variantId to be forced.

public static String getApptimizeAnonUserId ()

Get the current Apptimize-created anonymous user ID

This anonymous user ID will be used if-and-only-if the customer-specified user ID is null. A single anonymous user ID is created. If the customerUserId is set to a non-null value, then set back to null, Apptimize will use the same anonymous user ID as before.

Returns
  • the current Apptimize-created anonymous user ID

public static String getCustomerUserId ()

Get the current customer-specified userId

User IDs are arbitrary strings. If the customer-specified user ID is null, then Apptimize will create and use an anonymous user ID for tracking purposes. The initial default value of the customer-specified user ID is null.

Returns
  • The current customer-specified userId or null if not set

public static String getExperimentString (String varName, String defaultValue)

This method is deprecated.
Use stringForTest(String, String) instead.

Get the String associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createString(String, String) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

This method's options can be configured by instead calling stringForTest(String, String, ApptimizeOptions).

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
Returns
  • The String value this device should use for this A/B test variable.

public static Map<String, ApptimizeInstantUpdateOrWinnerInfo> getInstantUpdateOrWinnerInfo ()

Returns information about all winning Apptimize A/B tests and Instant Updates that the device is using.

The returned java.util.Map will contain one entry for each A/B test and instant update that the device showing. The key will be the name of the test or instant update, and the value will be the ApptimizeInstantUpdateOrWinnerInfo containing information about it. The return will be empty if this device has no winners or instant updates set.

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Returns
  • The java.util.Map with a ApptimizeInstantUpdateOrWinnerInfo for each winning A/B test and instant update that the device is displaying, or null if no information could be returned.

public static Map<String, ApptimizeInstantUpdateOrWinnerInfo> getInstantUpdateOrWinnerInfo (ApptimizeOptions options)

Returns information about all winning Apptimize A/B tests and Instant Updates that the device is using.

The returned java.util.Map will contain one entry for each winning A/B test and instant update that the device showing. The key will be the name of the test or instant update, and the value will be the ApptimizeInstantUpdateOrWinnerInfo containing information about it. The return will be empty if this device has no winners or instant updates set.

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Parameters
options Options for configuring this method. See ApptimizeOptions
Returns
  • The java.util.Map with a ApptimizeInstantUpdateOrWinnerInfo for each winning A/B test and instant update that the device is , or null if no information could be returned.

public static String getPilotTargetingId ()

public static Map<String, ApptimizeTestInfo> getTestInfo (ApptimizeOptions options)

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in. Note that this does NOT include information about Apptimize A/B tests or Feature Flags that are running but that this device is not enrolled in.

The returned java.util.Map will contain one entry for each A/B test and Feature Flag that the device is enrolled in. The key will be the name of the test or Feature Flag and the value will be the ApptimizeTestInfo containing information about this test. The return will be empty if this device is enrolled in no tests.

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Parameters
options Options for configuring this method. See ApptimizeOptions
Returns
  • The java.util.Map with a ApptimizeTestInfo for each A/B test and Feature Flag that the device is enrolled in, or null if this information could not be returned.

public static Map<String, ApptimizeTestInfo> getTestInfo ()

Returns information about all Apptimize A/B tests and Feature Flags that the device is enrolled in. Note that this does NOT include information about Apptimize A/B tests or Feature Flags that are running but that this device is not enrolled in.

The returned java.util.Map will contain one entry for each A/B test and Feature Flag that the device is enrolled in. The key will be the name of the test or Feature Flag, and the value will be the ApptimizeTestInfo containing information about this test. The return will be empty if this device is enrolled in no tests.

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Returns
  • The java.util.Map with a ApptimizeTestInfo for each A/B test and Feature Flag that the device is enrolled in, or null if no information could be returned.

public static Boolean getUserAttributeBoolean (String attributeName)

Get the value of a user attribute boolean.

Parameters
attributeName The attribute's name/key.
Returns
  • value The value of the attribute, or null if the attribute does not exist or is not of the Boolean type.

public static Double getUserAttributeDouble (String attributeName)

Get the value of a user attribute double.

Parameters
attributeName The attribute's name/key.
Returns
  • value The value of the attribute, or null if the attribute does not exist or is not of the Double type.

public static Integer getUserAttributeInteger (String attributeName)

Get the value of a user attribute integer.

Parameters
attributeName The attribute's name/key.
Returns
  • value The value of the attribute, or null if the attribute does not exist or is not of the Integer type.

public static String getUserAttributeString (String attributeName)

Get the value of a user attribute string.

Parameters
attributeName The attribute's name/key.
Returns
  • value The value of the attribute, or null if the attribute does not exist or is not of the String type.

public static String getUserId ()

This method is deprecated.
Use getApptimizeAnonUserId() instead.

Returns the java.lang.String user ID that uniquely identifies this device to Apptimize. This method will return null if the user ID could not be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called. In rare cases this method could return the empty string, like in the case where you have remotely disabled the Apptimize library.

Returns
  • The java.lang.String user ID that uniquely identifies this device to Apptimize, or, in uncommon cases where there is no user ID, either null or the empty string.

public static Map<Long, Map<String, Object>> getVariants (ApptimizeOptions options)

return information about all variants launched.

The returned java.util.Map will contain one entry for each variant in a currently running experiment. The returned java.util.Map will have the key as the variant's ID, and the value as another java.util.Map that maps java.lang.String key to their corresponding java.lang.Object values:
("variantId" : Long, "variantName" : String, "experimentId" : Long, "experimentName" : String). The return will be empty if there are no running experiments.

In rare cases where results come from old verions of Apptimize, the field 'experimentId' may be null;

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Parameters
options Options for configuring this method. See ApptimizeOptions
Returns
  • the java.util.Map for each variant launched, or null if this information could not be found

public static Map<Long, Map<String, Object>> getVariants ()

return information about all variants launched.

The returned java.util.Map will contain one entry for each variant in a currently running experiment. The returned java.util.Map will have the key as the variant's ID, and the value as another java.util.Map that maps java.lang.String key to their corresponding java.lang.Object values:
("variantId" : Long, "variantName" : String, "experimentId" : Long, "experimentName" : String). The return will be empty if there are no running experiments.

Note that it is also possible for this method to return null if no information could be returned; e.g., in the case where this method is called before setup(android.content.Context, String) is called.

Returns
  • the java.util.Map for each variant launched, or null if this information could not be found

public static void goalAchieved (String goalName)

Inform Apptimize a metric was achieved. Call this whenever a metric has been achieved. Note: This method will soon be deprecated. Use track(String) instead.

Parameters
goalName The metric's name.

public static int integerForTest (String varName, int defaultValue)

Get the int associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createInteger(String, Integer) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

This method's options can be configured by instead calling integerForTest(String, int, ApptimizeOptions).

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
Returns
  • The int value this device should use for this A/B test variable.

public static int integerForTest (String varName, int defaultValue, ApptimizeOptions options)

Get the int associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createInteger(String, Integer) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

Options can be configured using the input ApptimizeOptions.

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
options Options for configuring this method. See ApptimizeOptions
Returns
  • The int value this device should use for this A/B test variable.

public static boolean isFeatureFlagOn (String name)

public static boolean isFeatureFlagOn (String name, ApptimizeOptions options)

public static void metricAchieved (String metricName)

Inform Apptimize a metric was achieved. Call this whenever a metric has been achieved. Note: This method will soon be deprecated. Use track(String) instead.

Parameters
metricName The metric's name.

public static void removeOnExperimentsProcessedListener (Apptimize.OnExperimentsProcessedListener listener)

Remove an observer to be invoked when an Apptimize configuration is recalculated.

Parameters
listener The Apptimize.OnExperimentsProcessedListener to be removed.

public static void reset (boolean setupAgain)

public static void reset ()

Simulates a fresh install of Apptimize. For use in testing. All persisted data and attributes will disappear.

public static void runExperiment (String experimentName, ApptimizeExperiment experiment)

Executes an experiment. The code to run an experiment can be easily obtained from the Apptimize administration website. In it, you specify the experiment and variant names and it gives you code to paste into your app. It's best to cut and paste from the website to avoid typos. A single method on ApptimizeExperiment will be called synchronously (i.e. before the method returns). No reference to the ApptimizeExperiment instance is held or ever called again, unless you call runExperiment again. So in terms of control flow, this method works exactly like an if statement. Rather than using a code block test, we recommend controlling flow by creating an ApptimizeVar (whose value can be changed by A/B experiments) and then having an if/else or switch statement based on the value of the ApptimizeVar. Note: This method will soon be deprecated. Use runTest(String, ApptimizeTest) instead. This method's options can be configured by instead calling runTest(String, ApptimizeTest, ApptimizeOptions).

Parameters
experimentName The name of the experiment you're running.
experiment The code for the experiment. If the experiment is not currently running, the baseline method will be run.

public static void runTest (String testName, ApptimizeTest test, ApptimizeOptions options)

Executes a code block test. The code to run a test can be easily obtained from the Apptimize administration website. In it, you specify the test and variant names and it gives you code to paste into your app. It's best to cut and paste from the website to avoid typos. A single method on ApptimizeTest will be called synchronously (i.e. before the method returns). No reference to the ApptimizeTest instance is held or ever called again, unless you call runTest again. So in terms of control flow, this method works exactly like an if statement. Rather than using a code block test, we recommend controlling flow by creating an ApptimizeVar (whose value can be changed by A/B experiments) and then having an if/else or switch statement based on the value of the ApptimizeVar. Options can be configured using the input ApptimizeOptions.

Parameters
testName The name of the test you're running.
test The code for the test. If the test is not currently running, the baseline method will be run.
options Options for configuring this method. See ApptimizeOptions

public static void runTest (String testName, ApptimizeTest test)

Executes a code block test. The code to run a test can be easily obtained from the Apptimize administration website. In it, you specify the test and variant names and it gives you code to paste into your app. It's best to cut and paste from the website to avoid typos. A single method on ApptimizeTest will be called synchronously (i.e. before the method returns). No reference to the ApptimizeTest instance is held or ever called again, unless you call runTest again. So in terms of control flow, this method works exactly like an if statement. Rather than using a code block test, we recommend controlling flow by creating an ApptimizeVar (whose value can be changed by A/B experiments) and then having an if/else or switch statement based on the value of the ApptimizeVar. This method's options can be configured by instead calling runTest(String, ApptimizeTest, ApptimizeOptions).

Parameters
testName The name of the test you're running.
test The code for the test. If the test is not currently running, the baseline method will be run.

public static void setActiveCodeBlockForExperiment (String experimentName, String variationMethodName)

Set the active code block for a specific experiment

Parameters
experimentName name of the experiment
variationMethodName the variation method name being applied

public static void setActiveValueForDynamicVariable (ApptimizeVar<T> dynVar, T value)

Set the active value for a dynamic variable

Parameters
dynVar the dynamic variable
value the value of the dynamic variable

public static void setCustomerUserId (String customerUserId)

Set the current customer-specified user ID

User IDs are arbitrary strings, except that they cannot be the empty string "". When the customer-specified user ID is null, then Apptimize creates and uses an anonymous user ID for tracking purposes. If the customerUserId is set to a non-null value, then set back to null, Apptimize will use the same anonymous user ID as before. The initial default value of the customer-specified user ID is null.

Parameters
customerUserId the user ID string

public static void setMetric (String metricName, double value)

This method is deprecated.
Use track(String, double) instead.

Inform Apptimize that a numeric metric was achieved. A numeric metric is a noteworthy event associated with a numeric value that you wish to track. Call this whenever a numeric metric has been achieved, and this data will then be displayed in your results at apptimize.com.

For example, if the event you're interested in is a purchase event, you could call this method when a purchase is made and provide the price as the value. Then when viewing your results at apptimize.com you would be able to see the sum of the purchase prices.

Parameters
metricName The metric's name.
value The numeric value associated with this metric event.

public static void setOffline (boolean offline)

Set whether Apptimize should be in offline mode.

The default value for this setting is false. If set to true, Apptimize will not receive or send data until this setting is reset to false. This setting will persist across app restarts; e.g., if it is set to true and the app is restarted, Apptimize will still be in offline mode until this method is called with a value of false.

You may call this method before or after the Apptimize.setup() call. However, note that if you call this method and then do not call Apptimize.setup() before the app is destroyed, your requested setting will NOT be persisted for the next time the app is created.

Parameters
offline True to request offline mode, or false to reset to online mode.

public static void setOnApptimizeInitializedListener (Apptimize.OnApptimizeInitializedListener listener)

Register a callback to be invoked when Apptimize has completed setup and tests are available to be run.

Parameters
listener The Apptimize.OnApptimizeInitializedListener that will be invoked when an Apptimize has completed setup and tests are available to be run. This callback will only be run a single time, and will not fire if tests fail to be downloaded or if setup fails.

public static void setOnExperimentRunListener (Apptimize.OnExperimentRunListener listener)

This method is deprecated.
Use setOnTestRunListener(OnTestRunListener) instead.

Register a callback to be invoked when an Apptimize A/B test is run.

Parameters
listener The Apptimize.OnExperimentRunListener that will be invoked when an Apptimize A/B test is run. If this null then any previously set listener will be unset.

public static void setOnTestEnrollmentChangedListener (Apptimize.OnTestEnrollmentChangedListener listener)

Register a callback to be invoked when an Apptimize A/B test enrollment has changed.

Parameters
listener The Apptimize.OnTestEnrollmentChangedListener that will be invoked when an Apptimize A/B test enrollment changes. If this null then any previously set listener will be unset.

public static void setOnTestRunListener (Apptimize.OnTestRunListener listener)

Register a callback to be invoked when an Apptimize A/B test is run.

Parameters
listener The Apptimize.OnTestRunListener that will be invoked when an Apptimize A/B test is run. If this null then any previously set listener will be unset.

public static void setPilotTargetingId (String id)

public static void setTestmodeActive (boolean mode)

Activate the Apptimize SDK test mode (used for unit testing)

Parameters
mode if true, this method will activate the test mode which overrides normal sdk behavior. if false, this method will restore the sdk normal behavior

public static void setUserAttribute (String attributeName, int number)

Set a user attribute to be used in targeting/filtering/segmenting. You may call this before or after the Apptimize.setup() call. Attributes will be uploaded with your data so you can filter and segment on them in the Apptimize results browser. You can also use them to target users via the Apptimize frontend. If you want to do targeting of users based on these attributes, you should ideally set your attributes before calling Apptimize.setup().

Parameters
attributeName The attribute's name/key.
number The value of the attribute.

public static void setUserAttribute (String attributeName, String string)

Set a user attribute to be used in targeting/filtering/segmenting. You may call this before or after the Apptimize.setup() call. Attributes will be uploaded with your data so you can filter and segment on them in the Apptimize results browser. You can also use them to target users via the Apptimize frontend. If you want to do targeting of users based on these attributes, you should ideally set your attributes before calling Apptimize.setup(). Passing null as the value (the string parameter) has the same effect as calling clearUserAttribute.

Parameters
attributeName The attribute's name/key.
string The value of the attribute.

public static void setUserAttribute (String attributeName, boolean value)

Set a user attribute to be used in targeting/filtering/segmenting. You may call this before or after the Apptimize.setup() call. Attributes will be uploaded with your data so you can filter and segment on them in the Apptimize results browser. You can also use them to target users via the Apptimize frontend. If you want to do targeting of users based on these attributes, you should ideally set your attributes before calling Apptimize.setup().

Parameters
attributeName The attribute's name/key.
value The value of the attribute.

public static void setUserAttribute (String attributeName, double number)

Set a user attribute to be used in targeting/filtering/segmenting. You may call this before or after the Apptimize.setup() call. Attributes will be uploaded with your data so you can filter and segment on them in the Apptimize results browser. You can also use them to target users via the Apptimize frontend. If you want to do targeting of users based on these attributes, you should ideally set your attributes before calling Apptimize.setup().

Parameters
attributeName The attribute's name/key.
number The value of the attribute.

public static void setup (Context context, String appKey)

Initializes Apptimize with the default options. You should either call Apptimize.setup(this, "your app key") in all of your activities' onCreate methods or in your Application subclass. The latter is easier since you only need to add code in one place, but many Android apps do not specify a custom Application class (via http://developer .android.com/guide/topics/manifest/application-element.html#nm). Apptimize.setup() can be safely called multiple times and should be called on the main thread.

Parameters
context Your Context object (e.g., your Application or Activity). Usually just "this".
appKey The key provided to you by Apptimize. It links your app to your Apptimize account.

public static void setup (Context context, String appKey, ApptimizeOptions options)

Initializes Apptimize with the given options. You should either call Apptimize.setup(this, "your app key") in all of your activities' onCreate methods or in your Application subclass. The latter is easier since you only need to add code in one place, but many Android apps do not specify a custom Application class (via http://developer .android.com/guide/topics/manifest/application-element.html#nm). Apptimize.setup() can be safely called multiple times and should be called on the main thread.

Parameters
context Your Context object (e.g., your Application or Activity). Usually just "this".
appKey The key provided to you by Apptimize. It links your app to your Apptimize account.
options Options for configuring Apptimize. See ApptimizeOptions

public static String stringForTest (String varName, String defaultValue, ApptimizeOptions options)

Get the String associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createString(String, String) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

Options can be configured using the input ApptimizeOptions.

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
options Options for configuring this method. See ApptimizeOptions
Returns
  • The String value this device should use for this A/B test variable.

public static String stringForTest (String varName, String defaultValue)

Get the String associated with an Apptimize variable. Calling this method is the equivalent of defining an ApptimizeVar using createString(String, String) and then calling its value() method.

Note that this method will likely be deprecated soon in favor of using ApptimizeVar directly.

This method's options can be configured by instead calling stringForTest(String, String, ApptimizeOptions).

Parameters
varName The name of the Apptimize variable.
defaultValue The value to return if this device is not enrolled in any A/B experiments that affect this variable.
Returns
  • The String value this device should use for this A/B test variable.

public static void track (String eventName)

Inform Apptimize that an event occurred. For noteworthy events that you wish to track, you should call this method each time the event occurs. This data will then be displayed in your results at apptimize.com. Examples of events you could track include: purchases being made, login events, and Facebook shares.

If there is a numeric value associated with this event that you'd like to track and view at apptimize.com, use track(String, double) instead.

Parameters
eventName The event's name.

public static void track (String eventName, double value)

Inform Apptimize that an event occurred. For noteworthy events that you wish to track, you should call this method each time the event occurs. This data will then be displayed in your results at apptimize.com. Examples of events you could track include: purchases being made, login events, and Facebook shares.

If there is a numeric value associated with this event that you'd like to track and view at apptimize.com, provide it as the input parameter value. For example, if the event is a purchase, the value might be the price. If there is no such value, use track(String) instead.

Parameters
eventName The event's name.
value The numeric value associated with this event.