从 PDF 链接触发 Google Analytics 跟踪的技术

发布于 2024-09-15 13:12:17 字数 375 浏览 2 评论 0原文

场景如下:

我有一个包含 PDF 下载链接的邮件列表。 PDF 包含带有可点击链接的广告。我需要获取有关链接点击的分析数据 - 最好通过 Google Analytics(由于可用信息丰富)。

我想到的解决方案是让链接转到我使用某种特定于广告的令牌托管的网页。 GA 记录请求,然后我使用客户端技术重定向到实际的目标 URL。重定向页面除了跟踪点击之外没有其他任何用途,因此我并不担心它被搜索引擎视为隐藏内容。

我想知道的是:

  • 是否有其他方法可以在不使用中间重定向页面的情况下实现跟踪(我可以以某种方式调用 GA 服务器端)吗?
  • 如果我确实使用重定向页面方法,我可能会遇到哪些潜在的陷阱?

预先感谢您的任何建议。

Here's the scenario:

I have a mailing list that contains a PDF download link. The PDF contains ads with clickable links. I need to get analytic data on the link clicks - preferably via Google Analytics (due to the richness of information available).

The solution I have in mind is for the link to go to a web page that I host with some sort of ad-specific token. GA records the request and then I use a client-side technique to redirect to the actual target URL. The redirect page serves no purpose other than to track the click and so I'm not worried about it being perceived as cloaking by search engines.

What I want to know is:

  • Are there any alternative ways to achieve the tracking without using an intermediate redirect page (could I perhaps call GA server-side somehow)?
  • If I do use the redirect page approach, what are potential pitfalls could I encounter?

Thanks in advance for any advice.

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

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

发布评论

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

评论(1

半世蒼涼 2024-09-22 13:12:17

不知道您使用什么服务器端环境/语言,但例如在 php 中,您可以使用 cURL 向 google 发送图像请求,并将自定义代码附加到 url 中。最简单的方法是使用您的自定义代码使用 javascript 输出代码,然后使用嗅探器捕获图像请求 url,以便您可以复制 cURL 请求的格式。确保发送标头信息,包括虚假的浏览器信息,这样 GA 就不会将其作为机器人清除。然后转发到广告网址。这样你就不需要输出页面了。

是的,你仍然会发生“重定向”,但你不必让客户端下载页面或担心 javascript 被禁用等......

不幸的是,你确实没有什么更好的办法了。

dunno what server-side environment/language you use but for instance in php you can use cURL to send an image request to google, with the custom code appended to the url. Easiest way to do it is to output the code with javascript with your custom code and then capture the image request url with a sniffer, so you can replicate the format for your cURL request. Make sure to send header info, including fake browser info so GA doesn't weed it out as a bot. Then forward to the ad url. That way you don't need to output a page.

Yeah you still have a 'redirect' happening but you cut out having to have the client download a page or worry about javascript being disabled, etc...

unfortunately there really isn't anything better you can do.

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