Site Tracker Tag

You can track, measure and validate page views and events on your website in real-time via the client-side TrafficGuard Site Tracker tag.

Overview

The tag is comprised of two parts, a JavaScript tag and API. During on-load or on-click, Javascript executes an analysis of the clients' device or browser. Then, uses API to collect and send on-page behavioral data, of a whole user journey, to TrafficGuard to perform detection.

Is the Site Tracker Tag for you?

Use Site Tracker option if you are a website owner or a publisher who want to detect click fraud and analyse on-page behaviour of a visitor who clicks through and navigates around your website.

 

For more information on adding Measurement JS tag, checkout:

Installing Site Tracker Tag

To install the tag, copy integration snippet code and paste it inside <head> tag on every page of your site. Preferably as high in the <head> of the page as possible

Note:

When copy-pasting the tag below, you will need to specify parameters such as {property_id} with your own values. The property id can be found in your TrafficGuard Portal.

Site Tracker Tag Template

<!-- TrafficGuard Start -->
<script>
var dataTrafficGuard = dataTrafficGuard || [];
dataTrafficGuard.push(['property', '{property-id}']);
dataTrafficGuard.push(['event','pageview']);
(function() {
var tg = document.createElement('script'); tg.type = 'text/javascript'; tg.async = true;tg.src = '//tgtag.io/tg.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tg, s);
})();
</script>
<noscript><img src="//p.tgtag.io/event?property_id={property-id}&event_name=pageview&no_script=1" width="1" height="1" border="0"/></noscript>
<!-- TrafficGuard End-->

On-Page Tag request types

This table provides the custom API parameters which can be used to specify data-type field in the Site Tracker tag.

The following events are allowed for tracking

Request Type Details
'event' pageview
  registration
  addtocart
  checkout
  purchase
  login
  invite
  achievement
  share
  search
  goal

Adding custom parameters to Site Tracker Tag

This table provides a list of custom API parameters which can be used to specify data-trafficguard field in the Site Tracker tag.

 

ID API parameter Description

1

agency_id ID of the agency
2 app_id App package name as it appears in the store
3 campaign_id Campaign name or ID
4 creative_id Identifier of the ad creative
5 creative_set_id Identifier of the ad creative set
6 creative_type Type of ad creative (display, video)
7 gdpr GDPR Consent passing
8 gdpr_consent GDPR Consent passing - Encodes the consented-to purposes and vendor consent string, as obtained from the CMP JS API or OpenRTB.
9 gdpr_pd GDPR Consent passing - for generic URL parameters, gdpr_pd=0 indicates none of them contain personal data (from the perspective of the callee). For "defined" URL parameters, their definition should define whether they include personal data.
10 placement_id Identifier of the ad placement
11 section_id Identifier of section of the ad placement
12 siteid ID of the site or mobile app where the user was engaged
13 source_id Source id is integrated partner id on trafficguard platform
14 sub_param_1 Custom Parameter 1
15 sub_param_2 Custom Parameter 2
16 sub_param_3 Custom Parameter 3
17 sub_param_4 Custom Parameter 4
18 sub_param_5 Custom Parameter 5
19 sub_source_id Identifier of the sub-source or sub-publisher

 

Example for sending pageview event

<!-- TrafficGuard Start -->
<script>
var dataTrafficGuard = dataTrafficGuard || [];
dataTrafficGuard.push(['property', '{property-id}']);
dataTrafficGuard.push(['event', 'pageview']);
(function() {
var tg = document.createElement('script'); tg.type = 'text/javascript'; tg.async = true;tg.src = '//tgtag.io/tg.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tg, s);
})();
</script>
<noscript><img src="//p.tgtag.io/event?property_id={property-id}&event_name=pageview&no_script=1" width="1" height="1" border="0"/></noscript>
<!-- TrafficGuard End-->

Sending Custom DOM Events

TrafficGuard supports sending of custom events from users page i.e onclick or onload event. Sending event is only possible after Site Tracker Tag is initialised (and initial pageview event is sent)

Basic TrafficGuard event sender is called like this:

 

Javascript

TrafficGuard('event', '{event-name}', '{event-params}');


{event-name}
 - Event from predefined list supported by TrafficGuard
{event-params} - Some events require sending additional parameters

Event parameters can be passed in a few different formats as shown below:

Option 1. Formatted string in format key:value

HTML

<button 
onclick="TrafficGuard('event', 'purchase', 'is_conversion:1, event_revenue_usd:15');">
Purchase
</button>


Option 2. Object passed as parameter

Javascript

<button onclick="sendPurchaseEvent();"> Purchase </button> 
<script>
function sendPurchaseEvent(){
var event_params_object = {
is_conversion: 1,
event_revenue_usd: 15
};
TrafficGuard('event', 'purchase', event_params_object);
}
</script>