-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Google analytics pageview being triggered twice #12221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can confirm the same issue on 2.2.0. I changed as below and it seems to resolve the specific issue, it may have other consequences that I'm not yet aware of. At least with the Google Tag Assistant recording, I don't get the duplicate hits issue any more. Step 1. : Change the GoogleAnalytics/view/frontend/web/js/google-analytics.js file
Step 2: Remove deployed content and deploy it again, resolve any permission issues depending on your installation and language issues as well The error message in Google tag assistant recording, Google analytics report-tab prior to applying above:
|
I had made exactly the same change to mine as KarlComSe, and it resolve the issue from the pageview point of view. I've not looked more, but it does seem to be failing to track ecommerce though, with sales values not showing. |
@alexhadley I didn't test conversion tracking / sales tracking with the tag manager recording yesterday, but can see several orders from yesterday in Google Analytics. Those orders were made after the change to the .js-file. Hence, my conclusion is that above changes still tracks transactions. |
@alexhadley, thank you for your report. |
@magento-engcom-team, is there any update on this fix? We just moved to magento 2.2 and are seeing the same issue as above. Pageviews are being tracked twice which is causing bounce rates and pages per session to be incorrect. Ecommerce Tracking of transactional data is coming through correctly. |
Working on fixing this issue #MM18IN |
@bhargavmehta thank you for joining. Please accept team invitation here and self-assign the issue. |
Hi @alexhadley. Thank you for your report. The fix will be available with the upcoming patch release. |
Hi @alexhadley. Thank you for your report.
The fix will be available with the upcoming 2.3.0 release. |
I think that fix is not fully right because config.ordersTrackingData on the Success page is an object, so we can't check the 'length' property for this |
Conversion doesnt work here too. Ravinsky is right I guess. |
You have to modify the ga.phtml file to get the ecommerce tracking because as @ravinsky said you can't use .lenght on an object so you have to keep the old statement in the js file too: <?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block \Magento\GoogleAnalytics\Block\Ga */ ?>
<?php $accountId = $block->getConfig(\Magento\GoogleAnalytics\Helper\Data::XML_PATH_ACCOUNT) ?>
<?php $orderTrackingData = $block->getOrdersTrackingData() ?>
<!-- BEGIN GOOGLE ANALYTICS CODE -->
<script type="text/x-magento-init">
{
"*": {
"Magento_GoogleAnalytics/js/google-analytics": {
"isCookieRestrictionModeEnabled": <?= (int)$block->isCookieRestrictionModeEnabled() ?>,
"currentWebsite": <?= (int)$block->getCurrentWebsiteId() ?>,
"cookieName": "<?= /* @escapeNotVerified */ \Magento\Cookie\Helper\Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>",
<?php if (!empty($orderTrackingData)): ?>
"ordersTrackingData": <?= /* @escapeNotVerified */ json_encode($orderTrackingData) ?>,
<?php else: ?>
"ordersTrackingData": false,
<?php endif; ?>
"pageTrackingData": <?= /* @escapeNotVerified */ json_encode($block->getPageTrackingData($accountId)) ?>
}
}
}
</script>
<!-- END GOOGLE ANALYTICS CODE --> |
Hi @alexhadley. Thank you for your report. The fix will be available with the upcoming 2.2.6 release. |
Hi @alexhadley. Thank you for your report. The fix will be available with the upcoming 2.3.0 release. |
Preconditions
Steps to reproduce
Expected result
Actual result
It looks like a problem in the GoogleAnalytics/view/frontend/web/js/google-analytics.js file, line 54 on, which calls
ga('send', 'pageview'...
twice:`
The text was updated successfully, but these errors were encountered: