这是我的传奇--我试图在https://secure.example.com上将http://www.example.com链接到我的购物车上,但它似乎链接不正确。
下面是我的代码:
<!--Google Analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-125xxxxx-1");
//start cart link
pageTracker._setDomainName(".example.com");
pageTracker._setAllowHash(false);
//end cart link
pageTracker._trackPageview();
} catch(err) {}</script>
<!--Google Analytics -->请注意这两行:
pageTracker._setDomainName(".example.com");
pageTracker._setAllowHash(false);我添加了第一行,这样我就可以在站点和购物车之间共享cookie,并添加setAllowHash以确保它使用cookie中的utm值,而不是在我进入https://secure.example.com时“重新创建”它们。
使用firecookie,它确实在site和cart之间共享相同的cookie,并且cookie域是'example.com‘。
我非常确定,如果它工作正常,我所有的utmz、utma等值都应该被复制并保持不变,但它们正在发生变化。我已经复制了所有的参数,正在发送到谷歌分析,然后粘贴在下面。它显示了从我的主页,到我的产品页面,然后进入我的购物车一直到下单前的页面发生的事情。(如果不购买任何东西,我实际上无法亲自测试最终页面,所以如果需要,我会在稍后从我们的确认页面发布代码。)
如下所示:
===============================================================
HOMEPAGE - http://www.example.com
----------------------------------------------------------------------------------------
utmac UA-125xxxxx-1
utmcc __utma=1.1920057171.1269446996.1269446996.1269446996.1;+__utmz=1.1269446996.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
utmcs UTF-8
utmdt GSM Cell Phone Rental from example
utmfl 10.0 r45
utmhid 69978133
utmhn www.example.com
utmje 1
utmn 1806413990
utmp /
utmr -
utmsc 24-bit
utmsr 1280x800
utmul en-gb
utmwv 4.6.5
PRODUCT PAGE - http://www.example.com/products/international-cell-phone-purchase/
----------------------------------------------------------------
utmac UA-125xxxxx-1
utmcc __utma=1.1920057171.1269446996.1269446996.1269446996.1;+__utmz=1.1269446996.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
utmcs UTF-8
utmdt example | International Cell Phones
utmfl 10.0 r45
utmhid 276151647
utmhn www.example.com
utmje 1
utmn 155808433
utmp /products/international-cell-phone-purchase/
utmr 0
utmsc 24-bit
utmsr 1280x800
utmul en-gb
utmwv 4.6.5
CART STAGE 1 - https://secure.example.com/checkout/viewbasket.php
------------------------------------------------
utmac UA-125xxxxx-1
utmcc __utma=60286578.994269564.1269447144.1269447144.1269447144.1;+__utmz=60286578.1269447144.1.1.utmcsr=example.com|utmccn=(referral)|utmcmd=referral|utmcct=/products/international-cell-phone-purchase/;
utmcn 1
utmcs UTF-8
utmdt Your Cart
utmfl 10.0 r45
utmhid 1802074903
utmhn secure.example.com
utmje 1
utmn 1621444199
utmp 1-reviewcart
utmr http://www.example.com/products/international-cell-phone-purchase/
utmsc 24-bit
utmsr 1280x800
utmul en-gb
utmwv 4.6.5
CART STAGE 2 - https://secure.example.com/checkout/docheckout.php
------------------------------------------------
utmac UA-125xxxxx-1
utmcc __utma=60286578.994269564.1269447144.1269447144.1269447144.1;+__utmz=60286578.1269447144.1.1.utmcsr=example.com|utmccn=(referral)|utmcmd=referral|utmcct=/products/international-cell-phone-purchase/;
utmcs UTF-8
utmdt Checkout
utmfl 10.0 r45
utmhid 871670520
utmhn secure.example.com
utmje 1
utmn 1153927228
utmp 2-checkout
utmr 0
utmsc 24-bit
utmsr 1280x800
utmul en-gb
utmwv 4.6.5
CART STAGE 3 - https://secure.example.com/checkout/doreview.php
----------------------------------------------
utmac UA-125xxxxx-1
utmcc __utma=60286578.994269564.1269447144.1269447144.1269447144.1;+__utmz=60286578.1269447144.1.1.utmcsr=example.com|utmccn=(referral)|utmcmd=referral|utmcct=/products/international-cell-phone-purchase/;
utmcs UTF-8
utmdt Checkout
utmfl 10.0 r45
utmhid 1731598159
utmhn secure.example.com
utmje 1
utmn 1442257710
utmp 3-checkoutreview
utmr 0
utmsc 24-bit
utmsr 1280x800
utmul en-gb
utmwv 4.6.5
===============================================================如您所见,utma值没有保留,因此看起来像是配置问题。我研究过帮手,但似乎没有一个案例适合我。
我希望有人能在这方面提供帮助,这是我的一个持续的问题一段时间,并将很好地最终得到坚如磐石的可靠分析设置。
发布于 2010-04-15 21:25:11
实际上,我现在已经使用以下代码让它正常工作了:
<!--Google Analytics Asynchronous Code -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(
['_setAccount', 'UA-xxxxxxxx-1'],
['_setDomainName', '.domain.com'],
['_trackPageview']
);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--Google Analytics Asynchronous Code END-->发布于 2010-03-25 09:47:33
(我假设您已在配置文件设置中启用了电子商务报告。)
我相信你遗漏了一些样板文件(稍后会详细介绍)。此外,你在问题正文中提到的两行(在“开始购物车链接”和“结束购物车链接”之间)是不必要的。
在调用_trackPageview之后,需要另外三行,其中两行更新分别保存交易和存储商品数据的数组,最后一行调用_trackTrans()。这是您需要将您的信息发送到GA服务器的调用:
因此,在调用_trackPageview之后,插入以下三行:
pageTracker._addTrans(); // initializes a trans obj; stores trans data
pageTracker._addItem(); // array holding data for each item in the cart
pageTracker._trackTrans(); // confirms purchase, finalizes transaction 在对_trackTrans的调用中没有传递任何内容,但是您将为上面的两个函数调用传递参数。请记住,这两个函数的参数列表都按位置匹配,因此最好对不使用的参数使用占位符。这是一个显示参数列表的页面的link。
发布于 2010-03-31 10:41:15
看起来您在cart子域的JS中缺少以下几行:
pageTracker._setDomainName(".example.com");
pageTracker._setAllowHash(false);setDomainName设置Cookie域,setAllowHash(false)将utma cookie开头的域哈希转换为'1‘,而不是域名的数字哈希-在这种情况下并不是真的需要它,因为购物车与主站点在同一基域上,但如果您更改它,以前的用户cookie将不匹配。
不要对cookie的值太过兴奋(如果你修复了一些东西,你会同时看到旧的和新的cookie),用Firebug Net Panel测试一下,看看什么是真正的GA。
https://stackoverflow.com/questions/2509922
复制相似问题