nickurban
How to track usage of a LiveView app -- Google Analytics?
I’m wondering, perhaps I could track “page loads” in Google Analytics using hooks like on_mount, but mounted seems too limited, and beforeUpdate seems too general (it would fire even if the URL did not change, although perhaps I could check for that?)
Is there some other better way to track usage of a LiveView app?
Thanks!
Most Liked
harmon25
This is how I tackled the same issue but with analytics.js.
I think the phx:page-loading-stop event listener is the place to track live redirects/patches.
window.addEventListener("phx:page-loading-stop", (info) => {
//hides loading bar
topbar.hide();
// liveredirects/livepatches tracked as a page view
if (["redirect", "patch"].includes(info.detail.kind)) {
window.analytics.page();
}
});
lukeses
As LiveView uses browser’s pushState API, it is possible to use History Change Trigger in Google Tag Manager. Used approach might depend a bit, from which place, you want to control tracking in general. I was able to get an event in Google Analytics, whenever a path changes on LiveView page.
cgarvis
Last Post!
Exadra37
You now have a lib to provide Phoenix Analytics from the backend.
I took some notes and wrote also the code from the YoutubeVideo at Phoenix Analytics: open-source view tracking, in your app! - Video Pundits
Popular in Questions
Other popular topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #hex
- #security









