Frequently Asked Questions
Landing page builders

Trigger AnyTrack Events Programmatically

How to programatically trigger engagement events in AnyTrack.

Once the script placed on the webpage, a programmer can trigger manual event via the following commands:

Trigger a form submission event:

// trigger form submit event
var click_id = AnyTrack('formSubmit');

Trigger a Call To Action Event

// trigger call-to-action event
var click_id = AnyTrack('callToAction');

The return argument is the event {click_id} as string (for example: '9f3dqup94u79P6MRbunS4K'), and it should be used later on when triggering conversion events.

Event Details

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

const click_id = AnyTrack('formSubmit', {
id: 'my-link-id', // the link id
url: 'https://apple.com/referral', // the target event url
label: 'iPhone X', // event label
brand: 'Apple', // product brand name
product: 'iPhone', // product name
category: 'phones', // event category
commission: 2.1 // event monetary value,
});

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>
<script>
// handle the button click event
function handleBuyMe() {
// generate the click id
var click_id = AnyTrack('callToAction', { label: 'Buy Me' });
// redirect the browser to the store location with the click id param
window.location = 'https://some-store.com/?sub1=' + encodeURIComponent(click_id);
}
</script>