AnyTrack docs
🔗 Website🖐 Feature Requests⚙ Integrations👉 Sign up
  • Getting Started
  • Archive
  • docs
    • Advanced Settings
    • Elementor
    • Integrations
    • Taboola Integration
    • AnyTrack Guide to Conversion Tracking
    • The AnyTrack Tracking Code
    • Account Setup Tutorial
    • ⚒️Pixel & Analytics Integrations
    • Getting Started with AnyTrack
    • AnyTrack Core Features & Concepts
    • Conversion logic
    • AutoTrack
    • AutoTag copy from readme
    • AutoTag from Gitbook
    • AnyTrack Initial Setup
    • Google Tag Manager
    • Google Analytics integration
    • Enhance ROI: Facebook Postback URL for Affiliates
    • Facebook Conversion API and iOS 14 tracking restrictions
    • Affiliate Link Tracking
    • Form Submission Tracking
    • Form Tracking / Optins
    • Analytics & Reporting
    • Webhooks
    • Trigger Events Programmatically
    • Custom Events Names
    • Trigger Postbacks Programmatically
    • Redirectless tracking
    • Cross-Domain Tracking
    • Event Browser & Debugger
    • Fire Third-Party Pixels
    • Multi-currency
    • Frequently Asked Questions
    • Affiliate Networks Integrations
    • Partnerize integration
    • Affiliate Networks link attributes "cheat sheet"
    • Postback URL Parameters
    • ClickBank Instant Notification Services
    • Tune integration (AKA Hasoffers)
    • LeadsHook Integration
    • Frequently Asked Questions
    • Shopify Integration
    • Custom Affiliate Network Integration
    • Impact Postback URL
    • ShareAsale integration
    • IncomeAccess
    • HitPath
    • Phonexa
    • CJ Affiliates Integration
    • AWin integration
    • Pepperjam integration
    • Google Ads Integration
    • 💡Bing Ads server to server tracking
    • Outbrain Postback URL
    • Google Analytics Goals
    • External references & links
    • Google Ads Tracking Template
    • Google Analytics Goal Template
    • Affiliate network integration request
    • Troubleshooting guidelines
    • Convertri Integration
    • ClickFunnels Integration
    • Unbounce Integration
    • How AnyTrack works with link trackers plugins
    • Thirsty Affiliates
    • Redirection
    • Pretty Links Integration with AnyTrack
    • Difference between Search terms and search keyword
    • Facebook Server-Side API (legacy)
Powered by GitBook
On this page
  • Event Properties
  • Full Code Example
  • E-Commerce Support
  1. docs

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:

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

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 Properties

If you want to send additional properties along with the event, you can do so following the below format:

<script>
  AnyTrack('Purchase', {
    id: 'my-link-id', // link id
    url: 'https://apple.com/referral', // 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
  });
</script>

All fields are optional, but the data provided can be useful if you want to create your custom audiences with rich 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('OutboundClick', { 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>

E-Commerce Support

AnyTrack supports e-commerce parameters to track purchase of specific item ids:

<script>
  var click_id = AnyTrack('Purchase', {
    value: 29.9, // the total purchase value
    shippingPrice: 5.9, // optional shipping price
    taxPrice: 2.9, // optional taxes
    currency: 'EUR',
    transactionId: 'XJW0047',
    items: [{
      id: '20291', // the item catalog id (required)
      name: 'Sony MDRZX110/BLK ZX Series Stereo Headphones',
      quantity: 1,
      price: 19.9, // the item price (required)
    }, {
      id: '49292', // the item catalog id (required)
      name: '6.35mm Male to 3.5mm Female Headphone Stereo Audio Connector',
      quantity: 1,
      price: 4.1, // the item price (required)
    }],
  });
</script>
PreviousWebhooksNextCustom Events Names

Last updated 1 year ago