我一直在将代码从 Sweetalert 复制并粘贴到 Google 跟踪代码管理器中。它不会出现在预览中,并且在提交到网站后也不会出现。 Sweetlart 可以在 Google 跟踪代码管理器中运行吗? (我对此很陌生)
我做了什么:
<script src="//cdn.jsdelivr.net/npm/sweetalert2@11"></script>
和 触发:所有页面视图。 标签触发选项:每个事件一次
<script>
swal.fire({
title: "Do you need any consultancy service?",
text: "Let's",
type: "info",
confirmButtonColor: '#000000',
confirmButtonClass: "contactMeNow_popUpButton",
confirmButtonText: "Contact Me Now",
closeOnConfirm: true,
});
</script>
与 标签触发选项:每个事件一次 标签排序:Sweetalert 源代码(上图) 触发:所有页面加载窗口加载。
sweetalert 可以与 Google 跟踪代码管理器配合使用吗?我是不是在剧本或设定上做错了什么?
非常感谢您提前回复。
检查
chrome devtool
中的控制台错误。如果这不起作用,可能会出现一些错误。
稍微修改一下代码以检查
swal
是否存在
<script>
// try to console this variable is exist or not
console.log(typeof swal)
console.log(swal)
swal.fire({
title: "Do you need any consultancy service?",
text: "Let's",
type: "info",
confirmButtonColor: '#000000',
confirmButtonClass: "contactMeNow_popUpButton",
confirmButtonText: "Contact Me Now",
closeOnConfirm: true,
});
</script>
原因可能是即使您较早触发 js 标签。它不能保证第二个标签会哀嚎第一个标签加载完的js。
标签 1 已触发 ----> 标签 2 已触发 ----> 错误
js 开始加载 --------------> 它可能会在这里加载完成
在您的“sweetalert popup tag”标签配置中: 添加 : 标签排序:在“sweetalert popup tag”触发之前触发一个标签 并选择“sweetalert 弹出标签”。
一旦执行此操作,JS 代码将在之前加载,并且基于此代码的脚本将正确运行。
它在我的网站上运行良好。