Old FetchFromWithCookies

From ClickTale Wiki
Jump to: navigation, search
Please, use ClickTaleFetchFromWithCookies instead.
The only reason to use this code is if you have an old version of the recorder hosted and can't update it to the new one for some reason.


Contents

FetchFromWithCookies is an extension to the regular ClickTale tracking code that allows correct caching of pages that depend on cookie values. The cookies could contain session identifiers (session cookies) or simple values. The values collected during recording time will be passed to your server during the caching (AKA fetching) stage. Your server would then recognize a visitor's session on your website and render the page content accordingly (e.g. display a shopping cart's contents). This script is used in several integrations, including those for Classic ASP and JSP.

Using FetchFromWithCookies

  1. Below the script line referencing the WRb JavaScript file, add the following:
    <script type="text/javascript" src="http://s.clicktale.net/FetchFromWithCookies.js"></script>

    Note 1: If you are using HTTPS/SSL compliant code download and save FetchFromWithCookies.js in an https location, and change the script tag source to that location.

  2. For each cookie you would like to simulate, add the following line:
    FetchFromWithCookies.setFromCookie("[!COOKIENAME!]");

    Where [!COOKIENAME!] is replaced with the name of the cookie.
    Please note: The parameter setFromCookie can be either a String or a RegExp (Regular Expression), in order to accommodate cookies with a varying name. For example:

    FetchFromWithCookies.setFromCookie(/^ASPSESSIONID.*/);

    Can be user for recording cookies which are named "ASPSESSIONID" + an alphanumeric code, unique for each visitor.

  3. Finally, after the last cookie name (and before the line that starts with "if(typeof ClickTale=='function')"), add the code line:
    ClickTaleFetchFrom = FetchFromWithCookies.constructFetchFromUrl();

See here for Code_Examples

Specifying a URL

Much like the ClickTaleFetchFrom variable, the FetchFromWithCookies also enables you to define where to fetch the page html from (a different source than the page the code is located on). This is done by entering the URL as a parameter in the constructFetchFromUrl function:

ClickTaleFetchFrom = FetchFromWithCookies.constructFetchFromUrl([URL FOR HTML SOURCE]);

This can come in handy for instance when employing the ClickTaleFetchFrom solution for POST pages (noted here).

Using in conjunction with an integration module

Since integration modules have an xml file which is used as a centralized source for the tracking code, the FetchFromWithCookies should be implemented there. The addition of FetchFromWithCookies is done similarly to the way it's added to regular tracking code, with one exception. Since the code in the xml already includes a ClickTaleFetchFrom line, the URL in it should be used in the constructFetchFromUrl command instead. For example, The code in the ClickTaleScripts.xml file for the ASP.NET integration module contains the line:

ClickTaleFetchFrom="http://%RootPath%/ClickTaleCache.ashx?t=%CacheToken%";

When adding the FetchFromWithCookies code the reference to the FetchFromWithCookies.js file and the list of cookies added using setFromCookie is placed normally, while the ClickTaleFetchFrom line is changed to:

ClickTaleFetchFrom=FetchFromWithCookies.constructFetchFromUrl("http://%RootPath%/ClickTaleCache.ashx?t=%CacheToken%");
Personal tools