Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Our new script is backwards compatible so with a few adjustments to the code you can load Ice Cream Social’s v1 widget. This simplifies the installation of v1 as it no longer requires the addition of the cookie tracking script, which is incorporated instead in Ice Cream Social’s SDK.

The motivation behind supporting the v1 widget in the new script is to make the process of ultimately transitioning from using v1 to v2, once fully released, more seamless.

Two primary adjustments need to be made to the code snippet to support this:

  • Changing the line that specifies the version from version: 'latest' to version: 'v1'

  • Including addTransaction() function from the v1 integration script

After these changes are made, the resulting code will look like this (with some extraneous v2 lines removed for simplicity’s sake):

Code Block
<script>
    window.onIcsLoaded = function() {
      ICS.init({
        version: 'v1',
        publicKey: 'REPLACE',
        campaignId: 'REPLACE',
      });

  ics('addTransaction', {
    orderId: '{{order.order_number}}',
    email: '{{order.email}}',
    revenue: {{order.subtotal_price | money_without_currency}},
    name: '{{customer.name}}',
    inviteCookie: (document.cookie.match(/invite=([a-zA-Z0-9%]+)/) || [null] )[0],
    transactionId: '{{transactions[0].receipt.transaction_id}}',
    locale: 'sv-SE'
  });
  };

</script>
<script async defer crossorigin="anonymous" src="https://js.icecreamsocial.io/sdk.js" />

The values for the variables in the addTransaction() function should be changed to match how they will be used in your ICS integration.