Posted on 24/02/2023 12:47:59
Thank to clarify.
We already implemented the script in Swift_Master for a Swift 1.6.1. Google is receiving the data of the visits but not the data of the purchases.
What else do I need to do in order to receive the purchases?
The implemented at Swift_Master is this. The googleAnalyticsTrackingID has an empty value (because it is obsolete) and googleAnalyticsMeasurementID has a G-XXXXXXXXX value:
@* Global site tag (gtag.js) - Google Analytics *@
@if (!string.IsNullOrWhiteSpace(googleAnalyticsTrackingID) && allowTracking)
{
<script src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsTrackingID" async></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { window.dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', '@googleAnalyticsTrackingID');
</script>
}
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
bool isLoggedInBackendUser = false;
if (Dynamicweb.Environment.ExecutingContext.IsAdminLoggedIn()) {
isLoggedInBackendUser = true;
}
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode") && @isLoggedInBackendUser)
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
<script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
</script>
}