Frequently Asked Questions

Trigger Events Programmatically

How to programmatically trigger engagement & conversions events in AnyTrack.

Once you have added the AnyTrack tag on your webpage, a programmer can trigger programmatically any event via the following scripts:

// trigger an outbound click event
var click_id = AnyTrack('OutboundClick');

The event name could be any standard event name AnyTrack supports:

  • PageView

  • OutboundClick

  • FormSubmit

  • Lead

  • CompleteRegistration

  • Purchase

The return argument is the event {click_id} as string (for example: MAbFl0fhrE5EfBu6fX0FnL02LfS), and it can be used later on to attribute conversion events.

Event Details

If needed, it’s allowed to provide more details about the event in the following format:

var click_id = AnyTrack('FormSubmit', {
id: 'my-link-id', // link id
url: '', // the target link url
label: 'iPhone X', // link label
brand: 'Apple', // product brand name
value: 2.99 // event monetary value / commission
currency: 'EUR', // optional currency (default to propery currency)
transactionId: 'XJW0047' // transaction id

All fields are optional, but the data provided can be useful if you want to create your custom audiences with quality content.

Full Code Example

<button type="button" onclick="handleBuyMe">Buy Me</button>
// handle the button click event
function handleBuyMe() {
// generate the click id
var click_id = AnyTrack('OutboundClick', { label: 'Buy Me' });
// redirect the browser to the store location with the click id param
window.location = '' + encodeURIComponent(click_id);