JavaScript integration

Many websites use JavaScript dialog boxes/panels for various purposes. By default JavaScript induced elements are not automatically displayed in Playback. Specific JavaScript Support is required in order to display such elements. This article lists a few such additions for JavaScript support. Another possible method for capturing dynamic elements on the page is using the ActivePlayback API.

'''Please note: JavaScript in-page elements should not be confused with JavaScript pop-ups that open in a separate window. Popups that open in a separate window are separate pages and need to have the tracking code added to them if they are to be recorded.'''

Enabling dynamic JavaScript activation during playback
In order to trigger a JavaScript element which is normally triggered by visitor action (Click, hover on, CSS menus etc.), you should call the ClickTaleExec API function within the triggered JavaScript function. ClickTaleExec will register any action you pass to the function and will execute it during playback, thus enabling you for instance to expand/show a panel/dialog box.

Example 1: Hidden Div Element
If you have an HTML page with a button that when clicked shows a DIV html element, this is basically a simple case of a tab control or a DHTML menu. If the button onclick event is:

To record this change edit the function to include a call to ClickTaleExec in the following manner:

'Please note that the above is merely an example displaying a possible use of the ClickTaleExec'' function. The "ButtonClicked" function should be replaced with the relevant function which is to be triggered in Playback'''

Example 2: Drop-down Menu Panels (JS)
This is an example of using the ClickTaleExec API command to record a dynamic JavaScript menu. Each section of the menu is represented on the page using a list item which calls a JavaScript function entitled toggleMenu(or similar; Inspect Element can be used to find the exact function) when the visitor's mouse hovers over it. The menu items are constructed as follows: And the function itself looks like this: To record the function properly, an id attribute should be added to each list item: and the function should be changed to: Where "el" is the element, "elId" the ID added to the element and "over" is the toggle action. Note: As ClickTaleExec is part of an "if" statement it will only affect the menus during playback.

Also Note: Some Magento skins will include a 3rd parameter, in this case the following can be used:

A quick summary of the implementation:
 * 1) Right click the element on the page and select "Inspect Element" (in Firefox)
 * 2) Identify the function name and the parameters that control the movement to be recorded
 * 3) Perform the above ClickTaleExec additions to the function
 * 4) Add an ID to each menu item if one is not already defined.

Example 3: Drop-down Menu Panels (CSS)
If you are using drop-down menus that open by CSS manipulation, try the following method.

Use JavaScript with our ClickTaleExec API to simulate the ‘hover’ effect for the drop-down menu.



The HTML structure of the menu: -- -

The JavaScript to handle this example:

-- --

*jQuery can be added to any web page by simply adding the following script in the ‘’ of the file:

Example 4: Div Color Change (jQuery)
This is an example using jQuery. The changes in display are presented here:

The behavior may be recreated during playback based on visitor experience by adding the following:

Enabling dynamic JavaScript activation during aggregated reports
In case you wish to display in an aggregated report, elements which are hidden when the page initially loads and only appear as a result of visitor interaction, add the following code to make the elements visible:

The code will only be executed when the page is shown as a backdrop of one of ClickTale's aggregated report. The context object also stores information on which report is being displayed, enabling you to trigger different code in different aggregated reports. For more about this and other properties of the ClickTaleContext object, please see the playback time JavaScript API.