New Analytics Tracking Script Migration Guide Edit the file on GitHub

Google Analytics' javascript library (analytics.js) introduced a bug, which pollutes the global namespace (window) with an unexpected variable named 'sa'.
For more info you can check the bug report in Google's issue tracker.

The problem is that window.sa is also being used by many ecommerce sites with Skroutz Analytics which use the old Analytics Tracking Script.

In order to avoid conflicts with Google Analytics' code, it is necessary to perform the following changes.

Migration Steps

If you have already successfully integrated the Skroutz Analytics to your webpage you should follow the steps below in order to ensure that the service will continue to run normally:

  1. Use the new Analytics Tracking Script
  2. Replace sa() command queue with skroutz_analytics()

Skroutz Analytics for WooCommerce plugin

If your site's platform is built on WooCommerce and you are using Skroutz Analytics for WooCommerce plugin, you can just update the plugin and skip current migration guide's steps.

Table of Contents

Step 1: Use the new Analytics Tracking Script

Replace your old Analytics Tracking Script with the new one.

New Analytics Tracking Script

<!-- Add the Tracking Script and Connect to your Account -->
<script>
  (function(a,b,c,d,e,f,g){a['SkroutzAnalyticsObject']=e;a[e]= a[e] || function(){
    (a[e].q = a[e].q || []).push(arguments);};f=b.createElement(c);f.async=true;
    f.src=d;g=b.getElementsByTagName(c)[0];g.parentNode.insertBefore(f,g);
  })(window,document,'script','https://skroutza.skroutz.gr/skroutza.min.js','skroutz_analytics');

  skroutz_analytics('session', 'connect', 'SA-XXXX-YYYY');  // Connect your Account.
</script>
Note

You have to replace the 'SA-XXXX-YYYY' property with the actual Shop Account ID you received from us.

[Deprecated] Old Analytics Tracking Script

<script>
  (function(a,b,c,d,e,f,g){a[e]= a[e] || function(){
    (a[e].q = a[e].q || []).push(arguments);};f=b.createElement(c);f.async=true;
    f.src=d;g=b.getElementsByTagName(c)[0];g.parentNode.insertBefore(f,g);
  })(window,document,'script','https://skroutza.skroutz.gr/skroutza.min.js','sa');

  sa('session', 'connect', 'SA-XXXX-YYYY');  // Connect your Account.
</script>

Differences between Old and New Analytics Tracking Script

(function(a,b,c,d,e,f,g){a['SkroutzAnalyticsObject']=e;a[e]= a[e] || function(){
  (a[e].q = a[e].q || []).push(arguments);};f=b.createElement(c);f.async=true;
  f.src=d;g=b.getElementsByTagName(c)[0];g.parentNode.insertBefore(f,g);
})(window,document,'script','https://skroutza.skroutz.gr/skroutza.min.js','skroutz_analytics');

skroutz_analytics('session', 'connect', 'SA-XXXX-YYYY');  // Connect your Account.

Step 2: Replace sa() command queue with skroutz_analytics()

If you have completed the Step 1 you will have to replace all references to sa() with skroutz_analytics().

Ecommerce Commands

This change affects all Ecommerce Tracking commands you have already added to website's "thank you" page.

addOrder

old addOrder commands such as:

<script>
  sa('ecommerce', 'addOrder', JSON.stringify({
    // order's data
  }));
</script>

should be changed to:

<script>
  skroutz_analytics('ecommerce', 'addOrder', {
    // order's data
  });
</script>

addItem

old addItem commands such as:

<script>
  sa('ecommerce', 'addItem', JSON.stringify({
    // line item's data
  }));
</script>

should be changed to:

<script>
  skroutz_analytics('ecommerce', 'addItem', {
    // line item's data
  });
</script>

Complete Example

If you have followed Step 1 and Step 2, code in website's "thank you" page will look similar to the completed example below:

<!-- Add the Tracking Script and Connect to your Account -->
<script>
  (function(a,b,c,d,e,f,g){a['SkroutzAnalyticsObject']=e;a[e]= a[e] || function(){
    (a[e].q = a[e].q || []).push(arguments);};f=b.createElement(c);f.async=true;
    f.src=d;g=b.getElementsByTagName(c)[0];g.parentNode.insertBefore(f,g);
  })(window,document,'script','https://skroutza.skroutz.gr/skroutza.min.js','skroutz_analytics');

  skroutz_analytics('session', 'connect', 'SA-XXXX-YYYY');  // Connect your Account.
</script>

<!-- Send the Order data -->
<script>
  skroutz_analytics('ecommerce', 'addOrder', {
    order_id:      '123456',                // Order ID. Required.
    revenue:       '4417.58',               // Grand Total. Includes Tax and Shipping. Does not include payment costs.
    shipping:      '5.45',                  // Total Shipping Cost. Does not include payment costs.
    tax:           '1014.79',               // Total Tax.
    paid_by:       'example_paid_by',       // Payment method type, e.g. bank_transfer.
    paid_by_descr: 'Example paid_by_descr'  // Payment method description, e.g. Bank transfer.
  });
</script>

<!-- Send the Item data for each item in the shopping cart -->
<script>
  skroutz_analytics('ecommerce', 'addItem', {
    order_id:   '123456',                                    // Order ID. Required.
    product_id: '111222',                                    // Product ID. Required.
    name:       'Apple IPhone 6 Plus (16GB) Space Gray EU',  // Product Name. Required.
    price:      '654.90',                                    // Price per Unit. Required.
    quantity:   '4'                                          // Quantity of Items. Required.
  });

  skroutz_analytics('ecommerce', 'addItem', {
    order_id:   '123456',
    product_id: '303404',
    name:       'Motorola Nexus 6 (64GB) EU Light Gray',
    price:      '590.99',
    quantity:   '1'
  });

  skroutz_analytics('ecommerce', 'addItem', {
    order_id:   '123456',
    product_id: '121234',
    name:       'LG G4 (64GB) EU Leather',
    price:      '600.77',
    quantity:   '2'
  });
</script>