Please Update Your Snippet to our Universal Snippet

Attention Customers! We've updated our snippet code.

Since the start of the year, we’ve made some significant updates to our widget snippet and we’ve been moving customers gradually over to the new snippet. We’re calling the new snippet our “Universal Snippet” because you now use the exact same snippet for any site. The new version is better for a number of reasons.

Easier to configure

There’s no need to register a domain, just use the snippet on your sites and it works. If we see activity coming from a site we don’t recognize, we’ll reach out via email to let you know so we can sort out what action is required.

Easier to use

There’s no more need to change the domain_key for each development, staging, QA or production environment. All environments use the exact same code.

Loads faster

The new snippet uses an asynchronous method to load on the page, so it doesn’t matter where you place the snippet, it won’t affect your page’s performance.

Works with AMD

You can keep all your scripts in one place and still have the latest version of our widget code. We’ve tested it. If you need help integrating, let us know.

The first step in making our service better

The new snippet opens the door for us to add new features such as allowing you to make configuration changes from within our web app, instead of having to change your own code. This will make the widget easier to configure. Help us to improve our service.

How do I know if I need to update?

If you signed up a CloudSponge account in 2014 or earlier, then you probably need to update your snippet. Check your code on your site to confirm.

  • If you are using a domain_key in your csPageOptions, then you need to update your snippet.
  • If you are referencing address_books.js in your snippet, then you need to update.
  • If your snippet includes a Javascript file starting with //api.cloudsponge.com/widget/, then you should be good to go.

How do I update?

You should update your code with the following three changes.

Step 1: remove the old address_books.js script include from your page(s):

  <script type="text/javascript" src="//api.cloudsponge.com/address_books.js"></script>

Step 2: Replace the old address_books.js script with the new asynchronous snippet. Your own include will replace YOUR_WIDGET_SCRIPT with your widget script. Here’s a sample of what it looks like:

  <script>
    // Asynchronously include the widget library.
    // TODO: replace YOUR_WIDGET_SCRIPT with your widget script
    (function(u){
      var d=document,s='script',a=d.createElement(s),m=d.getElementsByTagName(s)[0];
      a.async=1;a.src=u;m.parentNode.insertBefore(a,m);
    })('//api.cloudsponge.com/widget/YOUR_WIDGET_SCRIPT.js');
  </script>

Step 3: remove domain_key from csPageOptions:

  window.csPageOptions = {
    // no more domain_key here
    // all other options can stay.
  }

That’s it! Now your are ready to verify your changes. Open your page in a web browser, launch the widget and do an import to confirm that your new snippet is working properly.

Where do I get my new snippet?

Click here for upgrade instructions specific to your account. Or get your full snippet here.

If neither of these links work for you, we are still upgrading your account. We’ll email you as your new snippet is made available for your account.

Reach out to support@cloudsponge.com if you have any questions as you proceed.

Graeme Rouse
CTO, CloudSponge

May 29, 2015

comments powered by Disqus