<form action="/charge.PHP" method="POST"> <input type='hIDden' name='productname' value='1_device'> <script src="https://checkout.stripe.com/checkout.Js" data-key="XXXYYYZZZ" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-name="Single" data-description=".99 monthly" data-panel-label="Subscribe" data-label="Single" data-amount="199" data-allow-remember-me="false"> </script></form><form action="/charge.PHP" method="POST"> <input type='hIDden' name='productname' value='5_device'> <script src="https://checkout.stripe.com/checkout.Js" data-key="XXXYYYZZZ" data-image="https://stripe.com/img/documentation/checkout/marketplace.png" data-name="Family" data-description=".99" data-panel-label="Subscribe" data-label="Family" data-amount="999" data-allow-remember-me="false"> </script></form>
有人知道在上面的代码中放置跟踪代码来跟踪转化和点击吗?谢谢
解决方法 捕获点击事件<script> document.body.addEventListener("click",function (event) { if (event.target.prevIoUsElementSibling.classList.contains("stripe-button")) { var data = event.target.prevIoUsElementSibling.dataset; } }); </script>
数据
所有数据都在数据集对象中单击后可访问:
/* All data fIEldsdata["key"]data["image"]data["name"]data["description"].replace(/\D/g,'');data["panel-label"]data["label"]data["amount"]data["allow-remember-me"]*/
使用Google Analytics事务处理数据
所有在一起应该是这样的:
<script>document.body.addEventListener("click",function (event) { if (event.target.prevIoUsElementSibling.classList.contains("stripe-button")) { var data = event.target.prevIoUsElementSibling.dataset; var transactionID = Math.random().toString(36).substr(2,10); var transactionValue = data["description"].replace(/\D/g,''); // set up ga ga('ecommerce:addItem',{ 'ID': transactionID,// Transaction ID. required. 'name': data["name"],// Product name. required. 'category': data["label"],// category or variation. 'price': transactionValue,// Unit price. 'quantity': 1 // Quantity. }); ga('ecommerce:addTransaction',// Transaction ID. required. 'revenue': transactionValue // Grand Total. }); ga('ecommerce:send'); }});</script>
文档
https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce
总结以上是内存溢出为你收集整理的使用HTML / Javascript中的分析跟踪条带转换全部内容,希望文章能够帮你解决使用HTML / Javascript中的分析跟踪条带转换所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)