Show Menu
TOPICS×

adobe.target.trackEvent(options)

This function fires a request to report user actions, such as clicks and conversions. It does not deliver activities in the response.
These event-tracking mbox calls can then be used to define metrics in activities. For more information, see Success Metrics and Track Conversions .
Here are the API details:
Key
Type
Required
Description
mbox
String
Yes
Mbox name
selector
String
No
CSS selectors used to find the HTML elements. The event listeners will be attached to found elements.
type
String
No
Represents a registered event type. It can be both HTML known events like: click, mousedown ,etc., as well as custom HTML events.
preventDefault
Boolean
No
Indicates whether to use event.preventDefault() in the event listener callback. Defaults to false.
Note : Only form[submit] and a #` are supported. Other scenarios are not supported due to complexity and huge amount of scenarios to support.
params
Object
No
Mbox parameters. An object of key-value pairs that has the following structure:
{ "param1": "value1", "param2": "value2"}
timeout
Number
No
Timeout in milliseconds.
If not specified, default value is used:
...timeoutInSeconds: 0.15...}
success
Function
No
A callback function used to signal that event has been reported.
error
Function
No
A callback function used to signal that event could not be reported.

Example

<a href="https://asite.com">click me!</a> 

plus javaScript code to assign trackEvent :
<script> 
$('a').click(function(event){ 
  adobe.target.trackEvent({'mbox':'homePageHero'}) 
}); 
</script> 

Or:
adobe.target.trackEvent({ 
    "mbox": "clicked-cta", 
    "params": { 
        "param1": "value1" 
    } 
});

In case the mandatory fields are not set, no request is executed, and an error is thrown.