我正在使用 Google Tag Manager 容器来管理脚本。我正在尝试执行服务器端优化/分析实验。出于性能原因,我需要服务器端。我已经使用 GTM/Optimize 容器很好地执行了客户端实验。
这是我的 GTM 代码:
window.dataLayer = window.dataLayer || [];
....
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXXX');</script>
<!-- End Google Tag Manager -->
我尝试了以下不同的方法来触发要触发的变化。
// These fn get called only once GA exists via setTimeout. They get called correctly.
// I've setup the experimentTrigger via GTM container and it triggers correctly to Analytics.
function setGAExperiment1(_expIdvId){
// Matches ga('set', 'exp', '$experimentId.$variationId');
// https://developers.google.com/optimize/devguides/experiments
ga('set', 'exp', _expIdvId);
dataLayer.push({'event': 'experimentTrigger', 'exp': _expIdvId }); // to trigger data send of exp
// I receive the experimentTrigger event with 'exp' value on Analytics but not any experiment data into Optimize/Analytics.
}
function setGAExperiment2(_expIdvId){
// Matches ga('set', 'exp', '$experimentId.$variationId');
// https://developers.google.com/optimize/devguides/experiments
ga('set', 'exp', _expIdvId);
ga('send', 'event', 'experiment', 'view'); // to trigger data send of exp
}
我在 Google Optimize 或 Google Analytics -> 行为 -> 实验中没有收到任何实验数据,就像我应该做的那样。我怎样才能解决这个问题?