Use custom parameters to send additional data points, such as conversions to TrafficGuard from your website, allowing for deeper granularity in your fraud analysis and reporting.
✅Prerequisite
The TG site tag must be initialized (and the initial pageview sent) before custom events can be triggered.
1 . Sending events
Events are sent by adding event snippets to your website. These snippets contain an event name and event parameters.
Example:
window.dataTrafficGuard.push(['event', 'event_name', 'eventParam']);
2. Implementation examples
Basic event
To track a simple action like a 'checkout':
window.dataTrafficGuard.push(['event', 'checkout', 'eventParam']);
Event with additional parameters
Pass additional data points—such as revenue or user IDs—can be passed as an array in the 'eventParam' value, such as the example of 'checkout' conversion event with revenue.
window.dataTrafficGuard.push(['event', 'checkout', '{"event_revenue_usd":"19.95", "is_conversion" : 1}']);
Event with additional parameters in JSON array
Pass additional data points—such as revenue or user IDs—using a JavaScript object. This is the recommended method for tracking conversions.
Track 'checkout' conversion event with revenue and user ID.
var goalParams = {
is_conversion: 1,
event_revenue_usd: "19.95",
user_id: "123"
};
window.dataTrafficGuard.push(['event', 'checkout', goalParams]);Triggering events on user actions
On-click event
Fire an event when a user clicks a button (e.g., "Share").
<div>
<button onclick="sendCustomEvent();"> Send Custom Event </button>
</div>
<script>
function sendCustomEvenType() {
window.dataTrafficGuard.push(['event', 'share', 'eventParam']);
}
</script>
On-load event
Fire a 'purchase' event on a page load.
<body onload="sendCustomEvent();">
<!-- web page content -->
<script>
function sendCustomEvenType() {
window.dataTrafficGuard.push(['event', 'purchase', 'eventParam']);
}
</script>
</body>
TrafficGuard event names
TrafficGuard supports the following predefined event names.
Note that these are case-sensitive.
pageview |
registration |
addtocart |
checkout |
purchase |
login |
invite |
achievement |
share |
search |
goal |
lead |
install |
open |
level |
tutorial |
viewcontent |
impression |
conversion |
deposit |
click |
session_start |
TrafficGuard event parameters
For a comprehensive list of all supported parameters (such as currency, order IDs, or custom dimensions), please refer to our Developer reference documentation.
