Advanced Event Tracking
Learn how to set up custom triggers in AnyTrack to track advanced user interactions on your website.
Track advanced user interactions—element visibility, time on site, webhooks, and DOM clicks—to capture conversion signals that standard tracking misses. Advanced triggers give you precise control over when events fire, so you can measure the actions that matter most to your ROAS.
Technical implementation requiredAdvanced tracking requires JavaScript, HTML, and CSS knowledge. If you're not comfortable with all three, share this guide with your developer.
Prerequisites:The AnyTrack Tag must be installed in your page
<head>section before any custom triggers will work.
Web Events Tracking
Track web events using the client-side snippet below. This is your foundation for all advanced tracking methods.
// trigger a lead event
var click_id = AnyTrack('trigger', 'Lead');
The snippet accepts standard Event Attributes to enrich events with customer data, product details, and context.
What gets tracked automatically:
- Page URL, title, and path
- First-party data (Google Analytics Client ID, Facebook cookies)
- Session context and UTM parameters
What gets sent server-side: Events are automatically forwarded to all connected ad platforms via Server-Side API (Conversion API), bypassing browser restrictions for complete data capture.
Example: An OutboundClick event structure:
{
"cid": "TZRImeinAR5B1V",
"ts": 1686737927708,
"pt": 1686737861561,
"en": "OutboundClick",
"dl": "https://readme.anytrack.io/docs/autotag",
"dt": "AutoTag",
"cp": [
{
"type": "ga",
"id": "UA-143868881-3",
"clientId": "1906187177.1686711792"
},
],
"id": "kv0bmJw0",
"tgid": "calendly",
"link": {
"id": "content-container",
"label": "Calendly Link.",
"url": "https://calendly.com/anytrack/"
}
}
Combine the basic snippet with the advanced tracking methods below to capture specific user behaviors.
Trigger an Event for Element Visibility
Track when users scroll to specific elements—useful for measuring engagement with key content, pricing tables, or CTAs before they click.
AnyTrack("onViewport", "#my-button", function() {
AnyTrack("trigger", "ViewButton");
});Use case: Measure how many visitors see your pricing before leaving, or track CTA visibility to understand drop-off points in your funnel.
Trigger a Webhook via a JavaScript Tag
Send conversion data to AnyTrack via webhook to connect external events (like CRM updates or payment confirmations) back to the original ad click. This enables offline conversion tracking for events that happen outside your website.
Setup required:
- Create a Custom Conversions source in AnyTrack.
- Copy the Postback URL and replace the URL in the snippet below.
<script>
AnyTrack('postback', 'https://t1.anytrack.io/xxxxx/collect?click_id={click_id}', {
brand: 'bar',
eventValue: 59.99,
transactionId: 'asfasdf'
});
</script>
Boost Event Match Quality:Enrich webhook events with customer data (email, phone) and product data (SKU, value, currency) to improve attribution accuracy and ad optimization. See the complete list of Event Attributes.
Track Time on Site
Measure visitor engagement by tracking time spent on your pages. Useful for identifying high-quality traffic sources and qualifying leads based on engagement depth.
setTimeout(function() {
AnyTrack('trigger', 'LongVisit');
}, 10e3);The example above triggers a LongVisit event after 10 seconds. Adjust the timeout value to match your engagement threshold (e.g., 30 seconds for blog posts, 60 seconds for pricing pages).
Use case: Create custom audiences of engaged visitors who spent 30+ seconds on your pricing page, or track which traffic sources deliver visitors who actually consume your content.
Trigger Events on DOM Element Clicks
Add click tracking to any HTML element—buttons, links, images, or custom components—to measure micro-conversions throughout your funnel.
<button onclick="AnyTrack('trigger', 'ClickViewDetails')">View Details</button>Use case: Track clicks on "View Demo," "See Pricing," or "Read More" buttons to identify high-intent visitors and build retargeting audiences based on specific interactions.
📽️ Watch this video to learn how to track button clicks
Disable tracking for specific pages
Stop the AnyTrack tag from loading on specific pages (like internal dashboards, admin pages, or thank-you pages you don't want to retarget). Add this snippet to the <head> section of pages you want to exclude:
<script>
AnyTrack('quiet');
</script>Use case: Prevent tracking on logged-in user dashboards, internal tools, or pages that would skew your analytics and retargeting audiences.
Disable Tracking for specific elements
The AutoTrack function automatically captures OutboundClick and FormSubmit events across your website. In most cases this is exactly what you want—but sometimes you need to exclude specific links or forms (like navigation menus, footer links, or internal tools).
Add class="at-do-not-track" to any element to exclude it from automatic tracking. This works on individual elements or container divs (which excludes all links and forms inside).
<a href="https://clickfunnels.com" class="at-do-not-track">UNTRACKABLE LINK</a>Use case: Exclude internal navigation, footer links, or frequently-clicked elements that would create noise in your conversion data without representing genuine user intent.
Updated about 5 hours ago
