简体   繁体   English

将 Angular 中的点击发送到 Google Pub/Sub

[英]Sending clicks in Angular to Google Pub/Sub

I'm new to the whole GCP stuff and I was wondering if I could send page clicks or other analytics data from my Angular application to Pub/Sub.我是整个 GCP 的新手,我想知道是否可以将页面点击或其他分析数据从我的 Angular 应用程序发送到 Pub/Sub。 I know that just using the basics of Google Analytics has a similar effect but I would really like to try sending the analytics data to Pub/Sub via custom code.我知道仅使用 Google Analytics 的基础知识会产生类似的效果,但我真的很想尝试通过自定义代码将分析数据发送到 Pub/Sub。

If I understand correctly, I can't just add a JavaScript snippet to my webpage which sends the data to a specific api url (eg. sending the time a user visits the website to gcloud.com/myTopic).如果我理解正确,我不能只在我的网页中添加一个 JavaScript 片段,该片段将数据发送到特定的 api url (例如,com 将时间发送到用户的 gcloud./myTopic) Do I really need to set up a Node.JS server which then sends the data to Pub/Sub or am I missing something?我真的需要设置一个 Node.JS 服务器,然后将数据发送到 Pub/Sub 还是我遗漏了什么?

You are correct.你是对的。 You have to build a server side part of your app where you send your metrics.您必须构建应用程序的服务器端部分,用于发送指标。

If you want to accept authenticated and unauthenticated metrics, it's challenging because you have to absorb possible attacks on your unauthenticated backend service.如果您想接受经过身份验证和未经身份验证的指标,这是具有挑战性的,因为您必须吸收对未经身份验证的后端服务的可能攻击。 The best solution is to use Google Analytics for unauthenticated metrics, and your service for authenticated users and custom metrics.最好的解决方案是将 Google Analytics 用于未经身份验证的指标,并将您的服务用于经过身份验证的用户和自定义指标。

In addition, you can sink the Google Analytics metrics into BigQuery for performing queries and extract the insight that you want.此外,您可以将 Google Analytics 指标输入 BigQuery 以执行查询并提取您想要的洞察力。 Do the same thing with your PubSub event.对您的 PubSub 事件执行相同的操作。 Optionally transform them and sink it into BigQuery.可以选择转换它们并将其放入 BigQuery。 A common place for all your metrics.所有指标的共同位置。 (You can optionally use Dataflow is you want to perform advanced transformation and groups per windows before storing (or in parallel) into BigQuery) (如果您想在存储(或并行)到 BigQuery 之前按 windows 执行高级转换和分组,您可以选择使用 Dataflow)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM