简体   繁体   中英

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. 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.

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). Do I really need to set up a Node.JS server which then sends the data to Pub/Sub or am I missing something?

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.

In addition, you can sink the Google Analytics metrics into BigQuery for performing queries and extract the insight that you want. Do the same thing with your PubSub event. Optionally transform them and sink it into 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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