E commerce Tracking is not working in nopCommerce 4.0

1 week ago
Hi.

I am trying to get Google Analytics working on our site.
We are using NopCommerce 4.0.

I have unchecked Disable "Order completed" page.

Code for widget:
<!-- Google code for Analytics tracking -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{GOOGLEID}', 'auto');
ga('send', 'pageview');
</script>

I have checked Enabled e-commerce.
I cannot see the the information being passed to google analytics for the ecommerce section.
If  manually enter the following code in the console, it works
ga('ecommerce:addItem', {
  'id': '1234',                     // Transaction ID. Required.
  'name': 'Fluffy Pink Bunnies',    // Product name. Required.
  'sku': 'DD23444',                 // SKU/code.
  'category': 'Party Toys',         // Category or variation.
  'price': '11.99',                 // Unit price.
  'quantity': '1'                   // Quantity.
});
ga('ecommerce:send');

Just not working on the normal pages

Please help
1 week ago
If you browse to your home page, and then right-click "view source", do a Find (ctrl-F) for  ga(
Does it find something like:
...("create","UA-...-2","....com");ga("send","pageview")
1 week ago
Yes pretty sure you need to go to order completed  page for it to add the order sales details

Code from Nop.Plugin.Widgets.GoogleAnalytics\Components\WidgetsGoogleAnalyticsViewComponent.cs
 
//Special case, if we are in last step of checkout, we can use order total for conversion value
var isOrderCompletedPage = controller.ToString().Equals("checkout", StringComparison.InvariantCultureIgnoreCase) &&
                    action.ToString().Equals("completed", StringComparison.InvariantCultureIgnoreCase);

Even then I have been told that the plugin now needs to be updated to send the correct info google now needs - See https://developers.google.com/tag-manager/enhanced-ecommerce#purchases

If you are looking for another option apparantly this plugin works https://www.foxnetsoft.com/documentation-nopgoogleenhancedecommerce
1 week ago
Yidna wrote:
Yes pretty sure you need to go to order completed  page for it to add the order sales details ...

Not always. Please see this code. If "GoogleAnalyticsSettings.UseJsToSendEcommerceInfo" setting is set to "true", then it'll be sent by requesting http://www.google-analytics.com/__utm.gif
1 week ago
This is the code rendered on the page.

      <!-- Google code for Analytics tracking -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '**Removed**', 'auto');
ga('send', 'pageview');
</script>

Everything works except the e-commerce section on google analytics.
As you can see the script section for that is not being rendered for some reason.