Track
Tracks a conversion event for a particular user for a running FullStack campaign.
Description
The API method:
- Validates the parameters passed.
- Checks whether the user is whitelisted.
- Checks if User Storage Service is provided to know whether the user is returning. If yes, show the previously assigned variation always.
- Assigns the consistent variation to the new/returning qualified user.
- Sends an impression event to the VWO server for generating reports.
The API method requires a campaign unique-key - campaignKey, unique user identifier - userId and the goal-identifier - goalIdentifer. You can also pass other flags under the options key.
campaignKey is the required key provided at the time of FullStack campaign creation.
userId is the required unique id associated with the user for identification.
goalIdentifier is the required key provided at the time of creating the goal in a FullStack campaign.
options is the optional key to provide targeting, whitelisting, User Storage Service stored data, and other flags based on your campaign setup and requirements.
Parameter Definitions
Parameter | Type | Description |
---|---|---|
campaignKey Required | String From v1.8.0+ String | Array | null/undefined/empty | The Campaign key to uniquely identify a FullStack campaign. From v1.8.0+ Campaign key, a list of campaign keys, or empty are supported as the type of parameter |
userId Required | String | User ID, which uniquely identifies each user. Important: This User ID must match the User ID provided to activate or getVariation API. |
goalIdentifier Required | String | The Goal key to uniquely identify a goal of a FullStack campaign. |
options Optional | Object | Pass params for pre-segmentation and whitelisting custom_variables(Object): Custom variables to be matched against Campaign's pre-segmentation. variation_targeting_variables(Object): Custom variation targeting variables to be matched against Campaign's forced variation/whitelisting conditions. revenue_value(Number | Float | String): Revenue goal value, necessary only when type of goal is revenue. goalTypeToTrack(String): If you want to track a particular goal across multiple campaigns(having the same identifier), use this flag to define which type of goal you would like to track i.e. conversion-only or revenue-only, or both. Defaults to ALL i.e. Conversion as well as Revenue goals. shouldTrackReturningUser(Boolean): Calling track APIs with same user ID will track that user multiple times in the campaign reports. Pass a true value to track only unique conversions of a particular user. This is applicable only if you've implemented a User Storage Service at your end. user_agent(String): userAgent of the visitor user_ip_address(String): IpAddress of the visitor |
Returns
A boolean value based on whether the impression was made to the VWO server.
Value | Type | Description |
---|---|---|
true | Boolean | If an impression event is successfully received by VWO server for report generation. |
false | Boolean | If userId provided is not part of campaign or when unexpected error comes and no impression call is received by VWO server. |
Usage
# For CUSTOM goal type
vwo_client_instance.track(campaign_key, user_id, goal_identifier, custom_variables = custom_variables, variation_targeting_variables = variation_targeting_variables, user_agent=user_agent, user_ip_address=user_ip_address)
# For REVENUE goal type
vwo_client_instance.track(campaign_key, user_id, goal_identifier, custom_variables = custom_variables, revenue_value = revenue_value, user_agent=user_agent, user_ip_address=user_ip_address)
Tracking Conversions for PAUSED campaign
If your server is using an old version of settings, VWO will discard any track calls for a campaign that is now in a Paused state. SDKs will keep on sending tracking hits for users or conversions for that campaign until you fetch the latest settings file and update your VWO client-instance.
Tracking goal having same identifier across different campaigns
When you want to track a goal having the same identifier across multiple campaigns, there is no need to trigger the goal for each different campaign individually. This will reduce the manual effort in case you plan to use the same goal in many campaigns. For example, in case you are planning to run 3 A/B tests and 4 Feature Tests, where you would be using the same goal, you don't have to trigger the goal having the same identifier for each of those 7 campaigns individually.
Same Goal Definition
A goal is considered to be the same when the goal identifier used for that goal is same across the multiple campaigns, irrespective of the type of campaign i.e. A/B or Feature Test Campaign.
VWO offers two types of goal i.e. Conversion and Revenue, which can be configured inside VWO application.
Tracking goal across campaigns only if goal-type is same
By default, SDK will track a goal across all running campaigns irrespective of the type of goal.
The behavior to configure and track only the specific type of goals is possible via passing a key either at the time of launching the SDK or inside the options parameter of the track API.
Passing the type of goal at the time of launching the SDK will consider the flag for all the track API calls. Defaults to ALL i.e. Conversion as well as Revenue.
# Available Goal_Types - GOAL_TYPES.REVENUE, GOAL_TYPES.CUSTOM, GOAL_TYPES.ALL (Default)
vwo_client_instance = vwo.launch(settings_file, goal_type_to_track=vwo.GOAL_TYPES.CUSTOM)
Passing the type of goal at the time of calling track API. This flag will be considered for the called track API. If you're using the track API at different places, please make sure to pass the flag in options at every instance.
# Available Goal_Types - GOAL_TYPES.REVENUE, GOAL_TYPES.CUSTOM, GOAL_TYPES.ALL (Default)
vwo_client_instance.track(campaign_key, user_id, goal_identifier, goal_type_to_track = vwo.GOAL_TYPES.CUSTOM)
Precedence Order of the goal-type flag
Goal Type key, as shown in example-code above, if present in track API will be given the priority over the same key provided even in the launch API.
Usage(when tracking same goal across campaigns)
# Tracking a goal of a particular campaign
vwo_client_instance.track('campaign-in-context', user_id, goal_identifier);
# Tracking a same goal across specific campaigns
vwo_client_instance.track(['campaign-1', 'campaign-2', 'campaign-3'], user_id, goal_identifier);
# Tracking a same goal across all valid campaigns
vwo_client_instance.track(None, user_id, goal_identifier);
Unique Conversions
VWO only tracks a conversion corresponding to a visitor hit only once even if the SDK sends multiple calls for the same user per campaign.
Updated 12 months ago