NOP 4.0 Google Analytics - problem with conversions? Analytics Widget problem/delete {ecommerce}?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Would love to see a way to do this with Google Tag Manager - but, since with GTM, you cannot edit the script to inject values, you must do this manually (at least after spending a few days on this, this is what I discovered).  GTM is worthless (for ad conversions with monetary amounts) for pretty much every website cart system unless it's WordPress.
3 years ago
tferderer wrote:
Hello,

So we just ran into this same problem and are in the process working through it, but I think this is a bug in the plugin that handles Google Analytics for Nop.

The way Google tracks conversions is using the gclid query string that gets appended to the landing page the customer enters. This id is then saved to a cookie.

Then, when a customer completes check out, the analytics tag uses that cookie to associate the transaction to the conversion.

However, it looks like in the Nop 4.0 code, the plugin is sending the transaction event from server side code instead of the client. So while it creates the transaction successfully in analytics, since it's sending from the server it doesn't associate with the the client's cookie that stores the gclid and shows up as a direct/none source.

I was able to edit our confirmation page to pull back the order information and implement the analytics transaction code directly on the page and now it seems to be working correctly for us.


tferderer wrote:

Hi,
Thanks for your quick reply.

I added like this as you mentioned in that thread.
\Nop.Web\Themes\Nitro\Views\Checkout\Completed.cshtml
In Completed page.
@{
    var _orderService = EngineContext.Current.Resolve<IOrderService>();
  var orderModelFactory = EngineContext.Current.Resolve<IOrderModelFactory>();
    var order = _orderService.GetOrderById(Model.OrderId);
    var orderDetails = orderModelFactory.PrepareOrderDetailsModel(order);
}

In the same page, I added in the bottom of the page


<script>
    ga('require', 'ecommerce');
    ga('ecommerce:addTransaction', {
        'id': '@orderDetails.Id',
        'affiliation': 'SITENAME',
        'revenue': '@orderDetails.OrderTotal.Replace("$", "").Replace(",", "")',
        'shipping': '@orderDetails.OrderShipping.Replace("$", "").Replace(",", "")',
        'tax': '@orderDetails.Tax.Replace("$", "").Replace(",", "")'
    });
    @foreach (var item in orderDetails.Items)
    {
        <text>
            ga('ecommerce:addItem', {
                'id': '@orderDetails.Id',
                'name': '@item.ProductName',
                'sku': '@item.Sku',
                'price': '@item.UnitPrice.Replace("$", "").Replace(",", "")',
                'quantity': '@item.Quantity'
            });
        </text>
    }
    ga('ecommerce:send');
</script>

**Enable E-commerce option is disabled in Google Analytics plugin configuration in the admin

But still not getting the different channel information. Problem with conversions.

Any suggestions, please.

Thanks,
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.