Implementation Steps - Step 3: Add script tag to site

There are two options for implementation. Either one works equally well. The first option is the ForeSee standard and uses just one line of JavaScript, so it requires a little less implementation. The second option may be useful for clients having areas of their site that tend to load slowly.

Remember
Unless previously discussed, this reference should be on every page of the site. Global JavaScript includes work great!

Option 1:

This is the standard implementation option using just one file reference. In most cases this method works fine.

The client must paste the following line of code as high up on the page as allowed. It is recommended to place the code between the <head> and </head> tags for optimum performance. However, this code typically runs fine from anywhere on the page.

<HEAD>
<script type="text/javascript" src="/foresee/foresee-trigger.js"></script>
</HEAD>

Note
The ‘files’ path of the JavaScripts mentioned here to point to the appropriate location of the files.

Option 2:

This option is favorable if the site uses a large amount of scripts and has areas that tend to load slowly. The OnExit survey relies on timers to know when the user has left the site before presenting the survey. Pages that load slowly may cause a timer to falsely identify an “exit” condition. This second option allows for the larger foresee-trigger.js file to be placed at the bottom of the site after other slower loading scripts, while the smaller foresee-alive.js is placed near the top above slower loading scripts. The foresee-alive.js is a very small file used only to alert the code that the session is still alive and to check for the foresee-trigger.js file to load before considering an exit condition.

The client must paste the reference to the foresee-alive.js file as high up on the page as allowed. It is recommended to place the code between the head tags for optimum performance.

The second reference to the foresee-trigger.js file can be placed anywhere lower on the page.

<HTML>
<HEAD>
<script type="text/javascript" src="/foresee/foresee-alive.js"></script>
</HEAD>
<BODY>
</BODY>
<script type="text/javascript" src="/foresee/foresee-trigger.js"></script>
</HTML>

Note
The ‘files’ path of the JavaScripts mentioned here to point to the appropriate location of the files.

Other articles in this section:

  1. Step 1: Receive survey trigger code
  2. Step 2: Save files to the Web Server
  3. Step 3: Add script tag to site (current article)
  4. Step 4: Testing Behavior and Presentation