1

We are using google analytics in our website but getting below error in console. Error: Uncaught SyntaxError: Unexpected token ':'

Script:

<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 ?>",
 "ordersTrackingData": <?= /* @escapeNotVerified */ json_encode($block->getOrdersTrackingData()) ?>,
 "pageTrackingData": <?= /* @escapeNotVerified */ json_encode($block->getPageTrackingData($accountId)) ?>
 }
 }
}
</script>
Ronak Rathod
6,58020 silver badges46 bronze badges
asked Dec 21, 2022 at 10:12

1 Answer 1

1

Not sure of the answer, but interestingly the syntax highlighting detects a change when it comes to the OrdersTrackingData, all the other keys are green, but this shows black. Could you maybe try removing this line, or the one above it and see if the error still occurs?

enter image description here

answered Dec 22, 2022 at 9:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.