使用 GTM 将自定义标签注入 Microsoft Clarity

Inject custom tag into Microsoft Clarity with GTM

具有用户定义的变量,例如{{username}},我想定义一个 MS Clarity 自定义标签

文档: https://docs.microsoft.com/en-us/clarity/custom-tags

clarity("set", "key", "value");

在 GTM 上下文中将是:

clarity("set", "username", {{username}});

GTM 清晰度自定义 HTML

<script type="text/javascript">
    (function(c,l,a,r,i,t,y){
        c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
        t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
        y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
    })(window, document, "clarity", "script", "apikey");
</script>

问题

MS 自定义标签部分 clarity("set"... 必须放在 GTM 中的什么位置?

请参考link https://support.google.com/tagmanager/answer/6107167?hl=en及以下示例。

<script type="text/javascript">
       (function(c,l,a,r,i,t,y){
       c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
       t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
       y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
       clarity("set", "username", {{username}});
       })(window, document, "clarity", "script", "apikey");
    </script>