Follow

Insert the JavaScript snippet

About this page

This page shows where to get and insert the Kaizen Platform JavaScript snippet for your A/B testing Experiments.

Get your JavaScript snippet

To start your Experiments with Kaizen Platform, you need to insert the JavaScript snippet into your site.
Each organisation gets its own snippet. Please follow these steps.

From the menu on the left side of the screen, select Settings and next the tab JS Snippet.
Your JavaScript snippet is in the black box. Click the Copy-button to copy the snippet to the Clipboard.

Where to insert your JavaScript snippet

The Kaizen Platform JavaScript snippet needs to be inserted on the page you want to test, your Experiment page (experiment page URL). And also on your Goal or conversion page (goal page URL).
How depends on the Experiment you want to perform. Look at these 3 options:

1. Your Experiment page URL and your Goal page URL are on the same domain

You have copied your JavaScript already, now:

  • paste it into these pages:
    • the page you want to test (your Experiment page)
    • your conversion page(your Goal page)

If you also add sub-goals on other pages, you have to paste the JavaScript snippet onto all of these pages

2. Your Experiment page URL and your Goal page URL are on different domains

When a visitor comes onto a page where an Experiment is performed, a Cookie is issued to the visitor to track his movements. But Cookies work only within the same domain.
Therefore, if the Experiment page and the Goal (or conversion) page are on a different domain, the Cookie must be handed over to the next domain.

  • To do this, paste your JavaScript into the following pages:
    • the page you want to test (your Experiment page)
    • your conversion page(your Goal page)
    • the last page of the first domain (in our example www.shop.com, that is the ‘Buy Now-button’)
    • the first page of next domain (in our example www.cart.com, that is the 'shopping cart’)

Next, go back to the last page of the first domain and add this snippet data-kz-track="outbound" to the tag.
This page could be a button or a <form>; you can use the same snippet (aka HTML attribute).

3. Your Experiment page URL and your Goal page URL are on the same domain but in the process a visitor leaves that domain (and comes back to it later)

This works the same as option 1.
You have copied your JavaScript already, now:

  • paste it into these pages:
    • the page you want to test (your Experiment page)
    • your conversion page(your Goal page)

Location to insert the JavaScript snippet

The JavaScript snippet should be inserted just before the closing </head>-tag.
If you cannot put the snippet before the closing </head>-tag, note the following points.

  • Any CSS files or JavaScript related to design should be loaded before the Kaizen Platform JavaScript snippet.
    • If such files are loaded after our snippet, it is possible that certain designs will not appear in your Experiment as you want them to be.
  • The time it takes to run an Experiment depends on the location of the JavaScript snippet.
    • Note that if you do not insert the snippet directly before the closing </head>-tag or directly after the opening<body>-tag, you could slightly delay the start of the Experiment.

Example of where to insert the JavaScript snippet:

<html>
<head>
<meta charset="UTF-8">
<title>Sample site</title>
<script data-kz-key="XXXXXX"
  data-kz-namespace="kzs"
  src="https://cdn.kaizenplatform.net/y/XX/ZZZZZZZ.js"></script>
</head>

Checking your JavaScript snippet

Please run a test to make sure that your JavaScript snippet is properly installed. To do this, use your browser on your installation page.
Here is an example using the Google Chrome Developer Tool.

  • open the page which now contains your JavaScript snippet on a Google Chrome browser.
  • in the browser menu, select more tools> Developer Tools.
  • open the Network tab and reload the page
  • make sure that the JavaScript file including your JavaScript snippet is loaded

from Developer Tools in the Google Chrome browser:

FAQ

I cannot place the JavaScript snippet between the and tags. Will my Experiment still run?

Yes, your Experiment will run as long as the snippet is on the page. However, your Experiment will not start until the JavaScript snippet of Kaizen Platform is completely read. Therefore, at the top of the page (between <head> and</head>)is best. If you cannot do that, we recommend to at least place it directly after the opening <body>-tag.

I have embedded the JavaScript snippet into both the test and conversion page, but thestatus of the JavaScript snippet does not update.

It takes some time for the snippet to update. Your Experiment-window does not update the status of the JavaScript snippet until the snippet itself has updated.

Does Kaizen Platform support tag management tools like Google Tag Manager?

From April 2015 both Google and Yahoo! tag managers are supported. Until than we do not.

Are there any reasons not to use tag management tools?

Tag management tools sometimes use asynchronous JavaScript. This makes it difficult to prioritize Kaizen Platform’s own Javascript and may cause a delay between the moment the page loads and your Experiment starts.
And tag management tools usually place themselves after the </head>-tag, making Experiments load even later.
So, to minimize the disruption to User Experience and to ensure the validity of data, we do not recommend the use of tag management tools. One exception could be on the Goal or conversion page.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.