npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gatsby-plugin-kameleoon

v1.0.6

Published

Gatsby plugin to easily add Kameleoon script — A/B Testing and personalization platform — to your site

Downloads

3

Readme

gatsby-plugin-kameleoon

Easily add Kameleoon — A/B Testing and personalization platform — to your Gatsby site.

Contents

Installation

npm install gatsby-plugin-kameleoon

How to use

By default, you should use the installation method recommended by Kameleoon, which consists of adding a script tag in the head of each page of your site with the anti-flicker option which avoids a bad user experience for your customers.

If you have no choice but to use a tag manager on your site, which is not recommended by Kameleoon, please read the following section about how to install Kameleoon with a Tag Manager.

If the methods below do not meet your needs, consider the following methods: install asynchronous script without anti-flicker or install synchronous script.

Besides these considerations, if you need to track your customers across different sites or subdomains that belong to you (different protocols are considered as different domains), you will need to additionally follow the cross-domain tracking implementation method.

Recommended implementation Method

Our official recommended implementation method is Asynchronous Loading, with Anti-Flicker. This recommended implementation is the safest one. Using an asynchronous script guarantees you that Kameleoon can not block the load your web site. And the added white overlay on the page "simulates" the effect of a synchronously loaded script, preventing flickering.

Edit the gatsby-config.js file as follows by setting only the siteCode option if you want to add the recommended script to your site.

// In your gatsby-config.js
plugins: [
  {
    resolve: "gatsby-plugin-kameleoon",
    options: {
      
      // see how to find your personnal site code (site ID) here: 
      // https://help.kameleoon.com/question/how-do-i-find-my-site-id/
      siteCode: "YOUR_SITE_CODE",
    }
  }
]

then follow the cross-domain tracking implementation method if you need to track your customers across different sites or subdomains.

Use with Tag Manager

This plugin is not able to finalize the installation of Kameleoon for you in this situation. To complete the installation of Kameleoon on your site, you will need to copy the following code snippet and paste it in your Tag Manager interface.

Remember to replace "YOUR_SITE_CODE" with your own in the snippet below. Read this Kameleoon documentation article if you need help finding your own site code.

var scriptNode = document.createElement("script");
scriptNode.src = "//YOUR_SITE_CODE.kameleoon.eu/kameleoon.js";
scriptNode.type = "text/javascript";
scriptNode.async = true;
scriptNode.setAttribute("data-tagmanager", true);
document.head.appendChild(scriptNode);

If you need to configure Kameleoon for cross-domain tracking, please edit the gatsby-config.js file as follows setting only the tagManager: true option then follow the cross-domain tracking implementation method.

// In your gatsby-config.js
plugins: [
  {
    resolve: "gatsby-plugin-kameleoon",
    options: { tagManager: true }
    // cross-domain tracking option, follow further instructions
  }
]

Install Asynchronous Script ( without Anti-Flicker )

Edit the gatsby-config.js file as follows if you want to install the asynchronous version of Kameleoon without anti-flicker and if you don't use a Tag Manager.

// In your gatsby-config.js
plugins: [
  {
    resolve: "gatsby-plugin-kameleoon",
    options: {
      
      // see how to find your personnal site code (site ID) here: 
      // https://help.kameleoon.com/question/how-do-i-find-my-site-id/
      siteCode: "YOUR_SITE_CODE",

      // specify the script to install 
      script: 'async'
    }
  }
]

Install Synchronous Script

Edit the gatsby-config.js file as follows if you want to install the synchronous version of Kameleoon if you don't use a Tag Manager.

// In your gatsby-config.js
plugins: [
  {
    resolve: "gatsby-plugin-kameleoon",
    options: {
      
      // see how to find your personnal site code (site ID) here: 
      // https://help.kameleoon.com/question/how-do-i-find-my-site-id/
      siteCode: "YOUR_SITE_CODE",

      // specify the script to install 
      script: 'sync'
    }
  }
]

Cross-Domain Tracking

Kameleoon offers support for cross-domain tracking which makes it possible to link sessions on several related sites as a single session. For instance, you may wish to consider that a visit started on https://portal.mysite.com and continued on https://transaction-engine.mysite.com or http://myothersite.fr (which are websites that you own) form a single visit. Note that for technical reasons, different protocols (such as HTTP and HTTPs) also count as different domains for Kameleoon.

To add cross-domain tracking capabilities to Kameleoon you should right-click to save the original iFrame file available here.

This iFrame will be loaded whenever, during the visitor's journey, the page URL does not match the main domain of the website. The iFrame HTML file is static and contains only immuable code used to save and restore visitor data in the Local Storage.

Inside the iFrame code, you should modify two variables (follow the comments inside the file to do so):

  • the value of the siteCode variable;
  • the value of the allowedDomains variable to remove a potential security / data leak vulnerability.

To finalize cross-domain tracking configuration edit the gatsby-config.js file as follows:

// In your gatsby-config.js
plugins: [
  {
    resolve: "gatsby-plugin-kameleoon",
    options: {
      // other options...
      crossDomainIframeURL: "https://www.yourdomain.com/path/to/kameleoon-iframe.html",
    }
  }
]

find more informations by reading Kameleoon's documentation: https://developers.kameleoon.com/tag-installation.html#cross-domain-tracking