Announcement

Collapse
No announcement yet.

How to upgrade to Google Analytics 4 (GA4)

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to upgrade to Google Analytics 4 (GA4)

    Your upgrade process is dependent on your Sellerdeck Desktop version:

    1. Version 18.2.0 onwards: In this case the required code is already present. This version also includes built-in support for Google Tag Manager. * NOTE: You still need to create the GA4 property in Google Analytics.
    2. Version 16.0.0 to version 18.1.2: You can upgrade the Google Analytics tracker script manually via the Sellerdeck Library, following the steps below. This method does not offer the built-in support for Google Tag Manager that comes with v18.2.0.
    3. Version 14 or older: GA4 is not compatible as the GA4 code relies on variables that are only available in version 16 onwards. Therefore we recommend you upgrade to v18.2.0 or later.

    * Whichever method you choose, you will need to set up a GA4 property afterwards via your Google Analytics account, following the steps provided by Google at: https://support.google.com/analytics/answer/9744165

    Upgrading a Sellerdeck v16.0.0 to v18.1.2 Site Manually

    Please note that if you use this method, and you subsequently upgrade your site to v18.2.0 or above, you should ignore any errors in the upgrade log that refer to the Google Analytics layouts, since the required changes have already been applied.

    To upgrade your v16 or v18 site without upgrading your software version to v18.2.0 or above, you must change the contents of the Google Analytics layouts as follows:

    1. Select ‘Library’ from ‘Design’ menu in Sellerdeck Desktop and click the ‘Layouts’ tab.
    2. Scroll down to the ‘Google Analytics Markup’ layout group.
    3. Double click on the layout ‘Google Analytics Item Details’ to open it
    4. Replace the entire contents of the layout with the following:
    Code:
    [<actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%20%3d%3d%20%22Receipt%22%29" >
    <script type="text/javascript">
    <!--
    act_productname = "<actinic:variable name="ProductNameOnlineBare" />";
    act_productname = act_productname.replace(rRemoveEncoded, " ");
    
    act_cart_item =
    {
    "id": "<actinic:variable name="ProdRef" />",
    "name": act_productname,
    "category": "",
    "quantity": "<actinic:variable name="Quantity" />",
    "price": act_price,
    };
    g_cart_items.push(act_cart_item);
    //-->
    </script>
    </actinic:block>
    5. Click ‘OK’
    6. Open the layout ‘Google Analytics Order Transmission’ and replace the entire contents with the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%20%3d%3d%20%22Receipt%22%29" >
    <script type="text/javascript">
    <!--
    <actinic:block if="%3cactinic%3avariable%20name%3d%22UseTagManagerForUA%22%20%2f%3e%20%3d%3d%20true" >
    if (typeof gtag !== "function")
    {
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    }
    </actinic:block>
    gtag('event', 'purchase', {
    "transaction_id": act_ordernumber,
    "affiliation": "<actinic:variable name="StoreName" />",
    "currency": "<actinic:variable name="DefaultIntCurrencySymbol" />",
    "value": act_total,
    "tax": act_tax,
    "shipping": act_shipping,
    "items": g_cart_items,
    "anonymize_ip": true
    });
    //-->
    </script>
    </actinic:block>
    7. Open the layout ‘Google Analytics Price’ and replace the entire contents with the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%20%3d%3d%20%22Receipt%22%29" >
    <script type="text/javascript">
    <!--
    var act_price = "<actinic:variable name="Price" />";
    act_price = act_price.replace(rConverDot, ".");
    act_price = act_price.replace(rRemoveEncoded, "");
    //-->
    </script>
    </actinic:block>
    8. Open the layout ‘Google Analytics Tracking Code’ and replace the entire contents with the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29" >
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22UseTagManagerForUA%22%20%2f%3e%20%3d%3d%20false%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%3d%3d%20%22Receipt%22%29" >
    <span class="gtmPageOverride" data-gtm-page="receipt.html"></span>
    </actinic:block>
    <actinic:block if="%3cactinic%3avariable%20name%3d%22UseTagManagerForUA%22%20%2f%3e%20%3d%3d%20false" >
    <actinic:variable name="GoogleAnalyticsMarkup" value="Google Analytics Page View" />
    <!-- Global Site Tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=<actinic:variable name="GoogleAnalyticsNumber" />"></script>
    
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', '<actinic:variable name="GoogleAnalyticsNumber" />',
    {
    'page_path' : GAPageName(),
    'anonymize_ip': true
    }
    );
    </script>
    </actinic:block>
    </actinic:block>
    9. Open the layout ‘Google Analytics Transaction Details’ and replace the entire contents with the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%20%3d%3d%20%22Receipt%22%29" >
    <script type="text/javascript">
    <!--
    var act_total = "<actinic:variable name="Total" />"
    act_total = act_total.replace(rConverDot, ".");
    act_total = act_total.replace(rRemoveEncoded, "");
    var act_tax = "<actinic:variable name="Tax1" />";
    act_tax = act_tax.replace(rConverDot, ".");
    act_tax = act_tax.replace(rRemoveEncoded, "");
    var act_shipping = "<actinic:variable name="Shipping" />"
    act_shipping = act_shipping.replace(rConverDot, ".");
    act_shipping = act_shipping.replace(rRemoveEncoded, "");
    //-->
    </script>
    </actinic:block>
    10. Open the layout ‘Google Analytics Variable Setup’ and replace the entire contents with the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22PageType%22%20%2f%3e%20%20%3d%3d%20%22Receipt%22%29" >
    <script type="text/javascript">
    <!--
    var act_order, act_item, act_ordernumber, act_productname, act_price, rConverDot, rRemoveEncoded;
    act_item = "";
    act_ordernumber = "<actinic:variable name="TheOrderNumber" />";
    rConverDot = new RegExp("&#46;", "g");
    rRemoveEncoded = new RegExp("&#\\d*;", "g");
    
    var g_cart_items = [];
    //-->
    </script>
    </actinic:block>
    11. You also need to add two new Library elements as follows:
    i. Right-click on the ‘Google Analytics Markup’ group and select ‘New Layout’, then proceed as follows:
    ii. Enter the Layout Name ‘Google Analytics Page View’ and click ‘OK’
    iii. Open the new ‘Google Analytics Page View’ layout and paste in the following:
    Code:
    <actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsGoogleAnalyticsEnabled%22%20%2f%3e%20%3d%3d%20true%29%20AND%20%28%3cactinic%3avariable%20name%3d%22UseTagManagerForUA%22%20%2f%3e%3d%3d%20false%29" >
    <script type="text/javascript">
    function GAPageName()
    {
    var sPageName = window.location.pathname + window.location.search;
    var override = document.getElementsByClassName('gtmPageOverride');
    
    if (override.length)
    {
    sPageName = override[0].getAttribute('data-gtm-page');
    }
    else if (window.location.pathname == '/')
    {
    sPageName = '/index.html' + window.location.search;
    }
    if (sPageName.substr(0,1) != '/')
    {
    sPageName = '/' + sPageName;
    }
    return sPageName;
    }
    </script>
    </actinic:block>
    iv. Click ‘OK’
    v. Click on the ‘Variables’ tab and scroll down to the ‘Site’ variable group.
    vi. Right-click the ‘Site’ groups and select ‘New Variable'.
    vii. Enter the Name ‘UseTagManagerForUA’.
    viii. Enter the Description ‘If Tag Manager is used for Google Analytics’.
    ix. Enter the Prompt ‘Use Tag Manager for Google Analytics?’.
    x. Change the Type to ‘True/False’ and set both the Initial Value and Top Level Value to ‘False’.
    xi. Click ‘OK’.

    12. Click ‘Close’ and upload the site to apply the Google script changes.

    To set up goal tracking in GA4 that matches the method recommended by Sellerdeck for UA, please refer to our Knowledge Base article: https://community.sellerdeck.com/for...racking-in-ga4
Working...
X