Google Analytics:使用表单发布方法进行跨域跟踪不起作用

时间:2015-09-01 09:00:33

标签: google-analytics cross-domain

我们有一个集成了第三方购物车的电子商店。 我们希望保留第三方购物车域中发生的转化的原始推介。

电子商店中的GA代码:

    <script type='text/javascript'>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-33333-1', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', ['3rdPartyCart.com'],false, true );
    ga('send', 'pageview');
    </script>

第三方中的GA代码:

<script type="text/javascript">
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    ga('create', 'UA-33333-1', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', ['e-shop.com'], false, true );
    ga('send', 'pageview');
</script>

购物车和电子商店都添加到GA的推荐排除列表中。

当访问者将广告投放到购物车并想要购买时,他/她必须点击“结帐”按钮,这是一个带有提交方法的表单,它会导致使用SSL的第三方购物车。 我们遵循了这些准则:https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autoforms,但它没有奏效。 文本中的简单链接导致购物车工作正常并生成?_ga = 1.99283479872.98324798274查询字符串,但表单没有。

任何帮助都会受到赞赏,我们真的需要这个工作......

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,但我可能会为您提供解决方案,具体取决于您对购物车的控制权。如果您对第三方购物车的服务器端有一定程度的控制权,则可以在订单表单的操作中将Google Analytics客户端ID作为查询字符串参数传递。

<form method="post" action="http://www.third-party-cart.com?clientId=000000">

然后,在购物车页面上,您可以通过执行类似

的操作将其作为GET参数进行检索
$clientId = $_GET['clientId']; 

在php或等效的购物车使用的任何服务器端语言。或者,您可以将其作为表单输入传递:

<form method="post" action="http://www.third-party-cart.com?">
    <input type="hidden" name="clientId" value="000000">
</form>

如果可能的话,你会在购物车页面上以某种方式检索它。根据您的购物车解决方案,可能会有一些允许传递的自定义变量,因此您可能希望查看这些变量。

相关问题