PhoneGap Plug-in Methods

You can use iOS PhoneGap Plug-in Methods to complete a variety of tasks.

Here is a link of the iOS PhoneGap Plug-in methods:

  • Configuration
  • Tracking
  • Target
  • Acquisition
  • Audience Manager
  • ID service

In html files where you want to use tracking, add the following to the <head> tag:

<script type="text/javascript" charset="utf-8" src="ADB_Helper.js"></script>

This section contains the following information:

Configuration Methods

Method

Description

getPrivacyStatus

Returns the privacy status for current user.

Here are the available statuses:

  • ADB.optedIn, where hits are sent immediately.
  • ADB.optedOut, where hits are discarded.
  • ADB.optUnknown

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

The default value is set in ADBMobileConfig.json

Example:

getPrivacyStatus(function (value) { myTempVal = value; }, function () { myTempVal = null; }); 

setPrivacyStatus

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

You can set one of the following statuses:

  • ADB.optedIn, where hits are sent immediately.
  • ADB.optedOut, where hits are discarded.
  • ADB.optUnknown

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

Example:

ADB.setPrivacyStatus('ADB.optedIn');

getLifetimeValue

Returns the lifetime value of the current user.

The default value is 0.

Example:

ADB.getLifetimeValue(function (value) { myTempVal = value; }, function () { myTempVal = null; }); 

setDebugLogging

Enables (true) or disables (false) viewing debug information. By default, this variable is false.

Example:

ADB.setDebugLogging(true);

getVersion

Gets the library version.

Example:

ADB.getVersion(function (value) { versionNum = value; }, function () { versionNum = 1.0; });

trackingIdentifier

Returns the automatically generated visitor identifier.

This is an app-specific unique visitor ID that is generated when the app is initially launched and is stored and used from that point forward. This ID is preserved between app upgrades, and is removed when the app is uninstalled.

Tip: If your app upgrades from the Experience Cloud 3.x to 4.x SDK, the previous visitor ID (custom or automatically generated) is retrieved and stored as the custom user identifier (see the getUserIdentifier row below). This preserves visitor data between upgrades of the SDK.

For new installations on the 4.x SDK, the user identifier is null and tracking identifier is used.

Example:

ADB.trackingIdentifier(function (value) { myTempVal = value; }, function () { myTempVal = null; });

getUserIdentifier

Returns the custom user identifier if a custom identifier has been set, and returns null if a custom identifier has not been set.

The default value is null.

Example:

getUserIdentifier(function (value) { myTempVal = value; }, function () { myTempVal = null; });

setUserIdentifier

Sets the user identifier to identifier.

Example:

ADB.setUserIdentifier('testUser');

setPushIdentifier

Sets the device token for push notifications.

Syntax:

ADB.setPushIdentifier(pushIdentifier, success, fail);

Example:

ADB.setPushIdentifier('test_push_identifier',function (value) { alert('success'); },function (value) { alert('fail'); });

keepLifecycleSessionAlive

Sets the preference of lifecycle session keep alive.

Important: Calling keepLifecycleSessionAlive prevents your app from launching a new session the next time it is resumed from background. You should only use this method if your app registers for notifications in the background.

Example:

ADB.keepLifecycleSessionAlive();

trackingSendQueuedHits

Forces the library to send all queued hits regardless of current batch options.

Example:

ADB.trackingSendQueuedHits();

trackingGetQueueSize

Gets or sets the number of stored tracking calls in the offline queue.

Example:

ADB.trackingGetQueueSize(function (value) { myTempVal = value; }, function () { myTempVal = null; });

trackingClearQueue

Removes all stored tracking calls from the offline queue. Warning: use caution when clearing the queue manually as it cannot be reversed.

Example:

ADB.trackingClearQueue(function (value) { myTempVal = value; }, function () { myTempVal = null; }); 

keepLifecycleSessionAlive

Indicates to the SDK that your next resume from background should not start a new session, regardless of the value of lifecycle session timeout in your config file.

Important: this method is intended to be used for apps that register for notifications while in background and should only be called from your code that runs while your app is in the background.

Example:

ADB.keepLifecycleSessionAlive();

collectLifecycleData

Indicates to the SDK that lifecycle data should be collected for use across all solutions in the SDK. For more information, see Lifecycle Metrics.

Example:

ADB.collectLifecycleData();

PII Methods

Method

Description

collectPII

Submits a PII collection request.

Syntax:

ADB.collectPII(piiData, success, fail);

Example:

ADB.collectPII({'k1':'v1','k2':'v2','k3':'v3'}, function (value) { alert('success'); },function (value) { alert('fail'); });

Tracking Methods

Method

Description

trackAdobeDeepLink

Tracks an Adobe Deep Link click-through.

Tip: If the Lifecycle call is a launch event, the Adobe Link data will be appended, otherwise an extra call will be sent.

Syntax:

ADB.trackAdobeDeepLink(deeplinkURL, success, fail);

Example:

ADB.trackAdobeDeepLink('xyz-deeplink-url', function (value) { alert('success'); },function (value) { alert('fail'); });

trackPushMessageClickthrough

Tracks a push message click-through.

Syntax:

ADB.trackPushMessageClickthrough(userInfo, success, fail);

Example:

ADB.trackPushMessageClickthrough({'k1':'v1','k2':'v2','k3':'v3'},function (value) { alert('success'); },function (value) { alert('fail'); });

trackLocalNotificationClickThrough

Tracks a local notification message click-through.

Syntax:

ADB.trackLocalNotificationClickThrough(userInfo, success, fail);

Example:

ADB.trackLocalNotificationClickThrough({'k1':'v1','k2':'v2','k3':'v3'}, function (value) { alert('success'); },function (value) { alert('fail'); });

trackState

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.

cData: JSON object with key-value pairs to send in context data.

Syntax:

ADB.trackState(string stateName[,JSON cData]);

Example:

ADB.trackState("login page");
ADB.trackState("login page", {"user":"john","remember":"true"});

trackAction

Tracks an action in your app. Actions are the things that happen in your app that you want to measure, include logins, banner taps, feed subscriptions and other metrics.

Syntax:

ADB.trackAction(string action[,JSON cData]);

Example:

ADB.trackAction("login");
ADB.trackAction("login", {"user":"john","remember":"true"});

trackActionFromBackground

Tracks an action that occurred in the background. This suppresses lifecycle events from firing in certain scenarios.

Syntax:

ADB.trackActionFromBackground(string action[,JSON cData]);

Example:

ADB.trackActionFromBackground("login");
ADB.trackActionFromBackground("login", {"user":"john","remember":"true"});

trackLocation

Sends the current x y coordinates. Also uses points of interest defined in the ADBMobileConfig.json file to determine if the location provided as a parameter is within any of your POI. If the current coordinates are within a defined POI, a context data variable is populated and sent with the trackLocation call.

Syntax:

ADB.trackLocation(x, y[,JSON cData]);

Example:

ADB.trackLocation('40.431596', '-111.893713');

trackLifetime​ValueIncrease

Adds amount to the user's lifetime value.

Syntax:

ADB.trackLifetimeValueIncrease(amount[,JSON cData]);

Example:

ADB.trackLifetimeValueIncrease('10.01');

trackTimed​ActionStart

Start a timed action with name action.

If you call this method for an action that has already started, the previous timed action is overwritten.

Tip: This call does not send a hit.

Syntax:

ADB.trackTimedActionStart(action[,JSON cData]);

Example:

ADB.trackTimedActionStart("cartToCheckout");

trackTimed​ActionUpdate

Pass in cData to update the context data associated with the given action.

The cData passed in is appended to the existing data for the given action, and overwrites the data if the same key is already defined for action.

Tip: This call does not send a hit.

Syntax:

ADB.trackTimedActionUpdate(String action[,JSON cData]);

Example:

ADB.trackTimedActionUpdate("cartToCheckout",{'SampleContextDataKey3':'SampleContextDataVal3','SampleContextDataKey4':'SampleContextDataVal4'});

trackTimed​ActionEnd

End a timed action.

Example:

ADB.trackTimedActionEnd("cartToCheckout");

trackingTimedActionExists

Returns whether or not a timed action is in progress.

Syntax:

ADB.trackingTimedActionExists(function (value) { myTempVal = value; }, function () { myTempVal = null; });

Target Methods

Method

Description

targetLoadRequest

Sends request to your configured Target server and returns the string value of the offer.

Syntax:

ADB.targetLoadRequest(success, fail, name, defaultContent, parameters);

Example:

ADB.targetLoadRequest(function (value)
{ myTempVal = value; }, function () { myTempVal = null; }, 'bannerOffer', 'none', {'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'});

targetLoadOrderConfirmRequest

Sends a request to your configured Target server.

Syntax:

ADB.targetLoadOrderConfirmRequest(success, fail, name, orderId, orderTotal, productPurchaseId, parameters);

Example:

ADB.targetLoadRequest(function (value) { myTempVal = value; }
, function ()
{ myTempVal = null; }
, 'name', 'orderId', 'total', 'purchaseId',
{'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'}
);

targetClearCookies

Clears the Target cookies from shared cookie storage.

Example:

ADB.targetClearCookies();

targetLoadRequestWithNameWithLocationParameters

Processes a Target service request.

Syntax:

ADB.targetLoadRequestWithNameWithLocationParameters(success, fail, name, defaultContent, profileParameters, orderParameters, mboxParameters, requestLocationParameters
);

Example:

ADB.targetLoadRequestWithNameWithLocationParameters (function () { alert('success'); }, function () { alert('fail'); }, 'bannerOffer', 'none', {'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'}, {'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'},{'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'},{'hp':'hp_val_new','hp.company':'adobe', 'hp.val2':'hp_val2'});

targetLoadRequestWithName

Processes a Target service request.

Syntax:

ADB.targetLoadRequestWithRequestName(success, fail, name, defaultContent, profileParameters, orderParameters, mboxParameters);

Example:

ADB.targetLoadRequestWithName(
function (value){  // handle target success},
function() { // handle target failure }, 
"mboxName",
"defaultContent",                                                                                                                        
{"profileParameters":"profileParametervalues"},                                                                                                              
{"orderId" : "32FGJ4XK" , "orderTotal" : "123.33" , "purchasedProductIds":"[46,34]" }, 
{"mboxParameters":"mboxParametersvalues"},                                                                                     
);

targetSessionID

Gets the value of the SessionID cookie returned for this visitor by the Target server.

Syntax:

ADB.targetSessionID (success, fail);

Example:

ADB.targetSessionID(function (value) { alert(value); },function (value) { alert('fail'); });

targetPcID

Gets the value of the PcID cookie returned for this visitor by the Target server.

Syntax:

ADB.targetPcID (success, fail);

Example:

ADB.targetPcID(function (value) { alert(value); },function (value) { alert('fail'); });

targetSetThirdPartyID

Sets the custom visitor ID for Target.

Syntax:

ADB.targetSetThirdPartyID(thirdPartyID, success, fail);

Example:

ADB.targetSetThirdPartyID('test-third-party-id', function (value) { alert('success'); },function (value) { alert('fail'); });

targetThirdPartyID

Gets the custom visitor ID for Target.

Syntax:

ADB.targetThirdPartyID(success, fail);

Example:

ADB.targetThirdPartyID(function (value) { alert(value); },function (value) { alert('fail'); });

Acquisition Methods

Method

Description

acquisitionCampaignStartForApp

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 (such as with an SKStoreView).

Syntax:

ADB.acquisitionCampaignStartForApp(appId, data, success, fail);

Example:

ADB.acquisitionCampaignStartForApp('0652024f-adcd-49f9-9bd7-2552a4564d2f', {'extraDataKey':'extraDataValue'}, success, fail);

Advertising Identifier

In the AppDelegate generated by Cordova, call [ADBMobile setAdvertisingIdentifier:] in the application:didFinishLaunchingWithOptions: delegate method.

See Configuration Methods.

Audience Manager Methods

Method

Description

audienceGetVisitorProfile

Gets the visitor’s profile.

Syntax:

ADB.audienceGetVisitorProfile();

Example:

ADB.audienceGetVisitorProfile(function(value) { profile = value; }, function() { profile = null; });

audienceGetDpuuid

Returns the DPUUID.

Syntax:

ADB.audienceGetDpuuid(success, fail);

Example:

ADB.audienceGetDpuuid(function(value) { dpuuid = value; }, function() { dpuuid = null; });

audienceGetDpid

Returns the DPID.

Syntax:

ADB.audienceGetDpid(success, fail);

Example:

ADB.audienceGetDpid(function(value) { dpid = value; }, function() { dpid = null; });

audienceSetDpidAndDpuuid

Sets the DPID and DPUUID.

Syntax:

ADB.audienceSetDpidAndDpuuid(dpid, dpuuid, success, fail);

Example:

ADB.audienceSetDpidAndDpuuid(‘dpid’, ‘dpuuid’, function() {…}, function() {…});
ADB.audienceSetDpidAndDpuuid(‘dpid’, ‘dpuuid’);

audienceSignalWithData

Processes an Audience Manager service request.

Syntax:

ADB.audienceSignalWithData(success, fail, data);

Example:

ADB.audienceSignalWithData(function() {}, function() {}, {‘key1’: ’value1’, ‘key2’: ‘value2’});
ADB.audienceSignalWithData({‘key1’: ’value1’, ‘key2’: ‘value2’});

audienceReset

Resets audience manager UUID and purges current visitor profile.

Example:

ADB.audienceReset();

ID Service Methods

Method

Description

visitorGetMarketingCloudId

Returns the Experience Cloud ID from the ID service.

Syntax:

ADB.visitorGetMarketingCloudId(success, fail);

Example:

ADB.visitorGetMarketingCloudId(function (value) { mcid = value; }, function () { mcid = null; });

visitorSyncIdentifiers

Synchronizes the provided identifiers with the ID service.

Syntax:

ADB.visitorSyncIdentifiers(identifiers, success, fail);

Example:

ADB.visitorSyncIdentifiers({‘key_id_1’:’value_id_1’}, function() {…}, function() {…}));
ADB.visitorSyncIdentifiers({‘key_id_1’: ‘value_id_1’}); 

visitorSyncIdentifiersWithAuthenticationState

Synchronizes the provided identifiers to the visitor ID service.

Syntax:

ADB.visitorSyncIdentifiersWithAuthenticationState(identifiers, authenticationState, success, fail);

Example:

ADB.visitorSyncIdentifiersWithAuthenticationState({'k1':'v1','k2':'v2','k3':'v3'}, ADB.mobileVisitorAuthenticationStateAuthenticated, function (value) { alert('success'); },function (value) { alert('fail'); });

visitorSyncIdentifierWithType

Synchronizes the provided identifier to the visitor ID service.

Syntax:

ADB.visitorSyncIdentifierWithType(identifierType, identifier, authenticationState, success, fail);

Example:

ADB.visitorSyncIdentifierWithType('test-identifier-type', 'test-identifier', ADB.mobileVisitorAuthenticationStateAuthenticated, function (value) { alert('success'); },function (value) { alert('fail'); });

visitorAppendToURL

Appends visitor identifiers to the given URL.

Syntax:

ADB.visitorAppendToURL(urlToAppend, success, fail);

Example:

ADB.visitorAppendToURL('test_visitor_url', function (value) { alert(value); },'');

visitorGetIDs

Returns all visitorIDs that have been synced.

Syntax:

ADB.visitorGetIDs (success, fail)

Example:

ADB.visitorGetIDs(function (value) { alert(value); },function (value) { alert('fail'); });