我目前正致力于通过Google跟踪代码管理器在Magento网上商店中集成Google Analytics增强型电子商务。
我正在使用Panalysis的扩展和指南:https://www.panalysis.com/resources/tag-manager-plus-user-manual/part-2c-set-gtm-tags
目前,我遇到了此代码的问题:
<script>
(function(){
function sendOneStepCheckout(obj){
dataLayer.push({
event: 'onestepcheckout',
ecommerce: obj
});
}
function hasClass( elem, clas ) {
try {
return (" " + elem.className + " " ).indexOf( " "+clas+" " ) > -1;
}catch(e){return false}
}
function checkActiveStep(){
var step2=document.getElementById('opc-login');
if (hasClass(step2, 'active')){ return '2' }
var step3=document.getElementById('opc-billing');
if (hasClass(step3, 'active')){ return '3' }
var step4=document.getElementById('opc-shipping');
if (hasClass(step4, 'active')){ return '4' }
var step5=document.getElementById('opc-shipping_method');
if (hasClass(step5, 'active')){ return '5' }
var step6=document.getElementById('opc-payment');
if (hasClass(step6, 'active')){ return '6' }
var step7=document.getElementById('opc-review');
if (hasClass(step7, 'active')){ return '7' }
}
var currentStep = '2';
try {
var ec = {{DL - ecommerce}};
var cos = ec.checkout.actionField.step;
if (cos == '1') {
ec.checkout.actionField.step = '2';
sendOneStepCheckout(ec);
}
if (cos == '2') {
sendOneStepCheckout(ec);
}
function timeout() {
setTimeout(function () {
var activeStep = checkActiveStep();
if (activeStep != currentStep){
var ec = {{DL - ecommerce}};
ec.checkout.actionField.step = activeStep;
sendOneStepCheckout(ec);
currentStep = activeStep;
}
timeout();
}, 1000);
}
timeout();
} catch(e){console.log(e.message)}
})();
</script>
Google跟踪代码管理器报告第43行出现错误,第2个符号:
“此语言功能仅支持ECMASCRIPT6模式或更好:块范围的函数声明。使用--language_in = ECMASCRIPT6或ECMASCRIPT6_STRICT或更高版本启用ES6功能。”
我尝试过搜索错误消息但没有成功。
谁能告诉我如何解决这个问题?我在这里碰到了我的头..
祝你好运, 基督教。
答案 0 :(得分:0)
Try deleting the <script>
tags, sometimes Google Tag Manager acts up if it is presented with code that isn't strict JS syntax.