Google Analytics:跟踪来自 Iframe 小部件的某些点击

发布于 2024-11-02 04:51:19 字数 397 浏览 1 评论 0原文

情况:

  • 有一个电子商务平台 myshop.com
  • 有一个联属合作伙伴,在 iframe 中集成了一个“迷你商店”,其中包含 src=myshop.com/widget
  • 在小部件内,我可以浏览类别并浏览它们
  • 单击链接时产品,myshop.com/manufacturer/product-x opens in a new window

复杂性:

  • 联属合作伙伴之间的支付模式基于 CPC,但仅限于产品点击(这意味着“逃离iframe”,如上所述)

问题:

  • 如何从 myshop.com 的角度跟踪这些点击,以便将它们聚合在 Google Analytics 中的某个位置?

Situation:

  • There is a ecommerce platform myshop.com
  • There is an affiliate partner that integrates a "mini shop" in an iframe with src=myshop.com/widget
  • Within the widget, I can navigate through categories and browse them
  • When clicking on a linked product, myshop.com/manufacturer/product-x opens in a new window

Complication:

  • The payment model between the affiliate partners is based on CPC, but restricted to clicks on products (which imply an "escape from the iframe" as described above)

Question:

  • How to track these clicks from the perspective of myshop.com so that they are aggregated somewhere in Google Analytics?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

天涯离梦残月幽梦 2024-11-09 04:51:19

实现此目的最安全的方法是要求合作伙伴在包含 iframe 时包含带有某种标识的查询参数。您需要这个,因为您无法访问外部窗口以从 iframe 内获取合作伙伴 url。因此,合作伙伴将插入以下代码:

<iframe src="myshop.com/widget?partner=StoreXYZ" />

现在,从 iframe 内部抓取该查询参数并将其与产品点击一起发送到分析。试试这个。 jQuery 代码。

$('.product').click(function(){
    var product = $(this).text() || 'Unknown Product';
    var partner = document.location.search;
    try{
        partner = partner.match(/partner=([^&]+)/)[1];
    }except(e){
        partner = 'None';
    }
    _gaq.push(['_trackEvent', 'PartnerClicks', partner, product]);
});

这只是一个例子。我试图获取产品名称和合作伙伴。并在点击产品时触发 Google Analytics 事件。

这将为您在“内容”>“事件跟踪”中提供一份不错的报告。
您可以检查每个合作伙伴或每个产品的点击次数,并将其中一个深入到另一个中。

请注意,Google Analytics 施加了一些限制,如果您有太多产品或合作伙伴,您可能会达到这些限制。

对于合作伙伴+产品组合,每个报告的限制为 50.000 个唯一值。

因此,如果您的合作伙伴数量乘以产品数量超过 50k,您可以考虑删除产品部分(只需省略 _trackEvent 的最后一个参数)。

如果您的合作伙伴数量超过了 50,000 个限制,那么您必须在其他工具(而不是 Google Analytics)上注册这些互动

The most secure way to achieve this is to ask the partners to include a query parameter with some kind of identification when including the iframe. You need this because you can't access the outer window in order to get partner url from within the iframe. So the partners would be inserting the following code:

<iframe src="myshop.com/widget?partner=StoreXYZ" />

Now from inside the iframe just grab that query parameter and send to analytics along with the product Clicks. Try this. JQuery code.

$('.product').click(function(){
    var product = $(this).text() || 'Unknown Product';
    var partner = document.location.search;
    try{
        partner = partner.match(/partner=([^&]+)/)[1];
    }except(e){
        partner = 'None';
    }
    _gaq.push(['_trackEvent', 'PartnerClicks', partner, product]);
});

This is just an example. I tried to get the product name and partner. And fire a Google Analytics Event when a product is clicked.

This will give you a nice report inside Content>Event Tracking.
You can check clicks per partner or per product, and drilldown any one into the other.

Be warned that Google Analytics impose some limitations and if you have too many products or partners you can reach those limits.

The limit is 50.000 unique values per report for the combination partner+product.

So if your number of partner multiplied by the number of products exceeds 50k you may consider dropping the product part (just omit that last parameter of _trackEvent).

If your number of partners alone exceeds the 50k limit, than you'll have to register those interactions at some other tool, instead of Google Analytics

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文