Tracker initialisation

 

Foreword

Before starting, please download our JavaScript library, or push it onto our CDN, from within the Tag Composer interface.

This library enables you to:

  • Set up your tagging perimeter/scope (site, domain used to write cookies, etc.).
  • Select desired features via configurable plugins.

Once the library is set up, you must call it inside the <head> of your page.

<!-- Local file -->
<script src="smarttag.js"></script>
<!-- CDN file -->
<!-- File must be published on the TDN for this site within Tag Composer -->
<script src="//tag.aticdn.net/YOURSITEID/smarttag.js"></script>
 

Initialisation

Tracker initialisation is done via JavaScript methods to be inserted.

<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>My Page</title>
		<script src="smarttag.js"></script>
	</head>
	<body>
		...
		<script type="text/javascript">			
			var tag = new ATInternet.Tracker.Tag();
		</script>
	</body>
</html>

The constructor ATInternet.Tracker.Tag() can take two arguments, a first one intended for overload Tracker configuration and a second intended for add context values.

 

Configuration

The file “smarttag.js” contains the default configuration defined during generation in Tag Composer. It’s possible to overload a part of the configuration by specifying the new settings during initialisation.

Example:

var tag = new ATInternet.Tracker.Tag({secure: true});

Here, the “secure” setup variable was force-set to true.

List of basic setup variables that can be overloaded:

  • The secure variable enables the sending of information in a secure manner, or not. Specify true in the case of an HTTPS protocol, and false for an HTTP protocol.
  • The disableCookie variable, if set to true, enables you to block the writing of tracker cookies (first and third).
  • The cookieDomain variable enables you to specify the domain for the writing of cookies. In cases where this parameter is empty (cookieDomain: ''), the domain of the current page will be used.

  • The cookieSecure variable, if set to true, enables you to add the option ‘secure’ for the writing of tracker cookies (first). Please be aware that ‘secure’ cookies will only work on HTTPS pages.
  • The ignoreEmptyChapterValue variable, if set to true, enables you to ignore chapters without value.

>= 5.5.0

Other setup variables exist, but require advanced knowledge of the Tracker (see Appendix).

 

Context

Its also possible to force context values which will be added and shared between tags according to the type.

Example :

var tag = new ATInternet.Tracker.Tag({}, {'forcedCampaign': 'campaignValue'});

Here, the campaign value defined in “forcedCampaign” will be added in page tags.

List of context variables that can be declared :

  • The forcedCampaign enables you to declare and force a campaign.
  • The forcedReferer variable enables you to declare and force a referer.
 

Basic tag

Here is an example of a tag allowing you to measure a pageview with the label “Page Name”:

<script type="text/javascript">			
  var ATTag = new ATInternet.Tracker.Tag();
  ATTag.page.send({name:'Page_Name'});
</script>
 

Appendix

Setup variables that can be overloaded:

NameDefault valueDescriptionVersion
securefalseForce the sending of information in a secure manner (HTTPS)
disableCookiefalseEnables you to block the writing of tracker cookies (first and third)
cookieDomainTagComposer valueDomain for the writing of cookies. If this parameter is empty (cookieDomain: ''), the domain of the current page will be used
cookieSecurefalseAdd option ‘secure’ for the writing of tracker cookies (first)>= 5.5.0
ignoreEmptyChapterValuetrueIgnore chapters without value>= 5.5.0
siteTagComposer valueSite number
logTagComposer valueSubdomain of the collector AT Internet. Deprecated since 5.13.0, see collectDomain< 5.13.0
logSSLTagComposer valuesubdomain of the secured (HTTPS) collector AT Internet. Deprecated since 5.13.0, see collectDomain< 5.13.0
domainTagComposer valueDomain of URL hits. Deprecated since 5.13.0, see collectDomain< 5.13.0
pixelPath/hit.xitiPath toward the pixel file for hits
previewfalseForce the sending of page hits in cases of loads in preview mode on the Safari browser (true: measurement enabled, false: measurement disabled)
collectDomainTagComposer valueData collection domain>= 5.13.0
collectDomainSSLTagComposer valueSecured data collection domain>= 5.13.0
sendHitWhenOptOutTagComposer valueAllows sending anonymous hits when the user is in “OPT-OUT” mode (first party)>= 5.14.0
 

Was this post helpful?

Last update: 13/03/2019