Insert the JavaScript for the SAS Tag
- Insert the Standard SAS Tag (including the JavaScript Events API)
- Insert Only the JavaScript Events API Version 2
For each page that you want to monitor, insert the SAS tag in your site's HTML. The tag enables you to collect a client's web behavior and enables web personalization and digital marketing. Before you add the SAS tag to your site, review the topic (Optional) Advanced Options and Best Practices to review options and examples.
In addition, the SAS tag and related APIs are limited by a customer’s cookie and tracking settings. For more information, see Limitations on Data Collection with Web Events in SAS Customer Intelligence 360: User’s Guide.
Insert the Standard SAS Tag (including the JavaScript Events API)
Inserting this tag enables the features of the
standard SAS tag and takes advantage of JavaScript preloading. JavaScript preloading
can
provide a performance boost on modern browsers. On older browsers (such as Internet
Explorer
9) and browsers that do not recognize the async attribute, loading
and execution falls back to synchronous operation.
Follow these instructions to get the JavaScript code to insert:
Click
Administration
Tasks. Then click SAS Tag Instructions in
Digital.- Copy the JavaScript code on the
SAS Tag Instructions page. Add the code to the head tag of your
site's pages (loading it as early as possible). The JavaScript function is similar
to this
example:
<script> (function(ci,a){window[ci] || function(){var ef=window[ci]=function(){return ef.q.push(arguments);};ef.q=[];ef.a=a||{};}();}) ('ci360',{tenantId:'<tenant ID>'}); </script> <script async data-efname='ci360' src='https://<CNAME>/js/ot2.min.js' id='ob-script-async' ></script>To enable compatibility for preloading the script with older browsers, also include this snippet as early as possible in your pages:
<link rel='preload' href='https://<CNAME>/js/ot2.min.js' as='script'/>The examples use <CNAME> as a variable in the domain. The CNAME should be configured when you initially set up SAS Customer Intelligence 360. These steps are described in the SAS Customer Intelligence 360: Environment Setup Guide.
CAUTION
Do not modify the SAS tag with additional logic or code. Modifications to the SAS tag are not supported and might cause issues with its operation. Contact SAS technical support if you have a special case that needs to be considered.
Insert Only the JavaScript Events API Version 2
Use the tag that loads only version 2 of the JavaScript Events API. Use this option when you want to explicitly send events and do not want to collect anything by default.
In addition, the embedded site browser in SAS Customer Intelligence 360 is not currently integrated with the API-only version of the SAS tag (ot-api.min.js). If you create events in the user interface, you must manually set the page locations, page elements, selectors, and so on.
Add the following script element into your site’s HTML:
<script>
(function(ci,a){window[ci] || function(){var ef=window[ci]=function(){return ef.q.push(arguments);};ef.q=[];ef.a=a||{};}();})
('ci360',{tenantId:'<tenant ID>'});
</script>
<script async data-efname='ci360' src='https://<CNAME>/js/ot-api.min.js' id='ob-script-async' ></script>
To enable compatibility for preloading the script with older browsers, also include this snippet as early as possible in your pages:
<link rel='preload' href='https://<CNAME>/js/ot-api.min.js' as='script'/>
By enabling JavaScript preloading, you can send events through the JavaScript Events API before the tag is fully loaded. Events are queued and sent when the SAS tag is ready, so you do not need to verify that the API is ready before you call it.