analytics/lib/plausible_web/templates/layout/_tracking.html.heex
Karl-Aksel Puulmann 499be9f0b3
Add more custom properties to be tracked (#3778)
We just released support for multiple custom property filters, but our demo/live setup
does not have many useful custom properties. This PR adds a few more to allow
better slicing-and-dicing.
2024-02-12 11:11:19 +02:00

30 lines
1022 B
Plaintext

<%= on_full_build do %>
<%= if !@conn.assigns[:skip_plausible_tracking] do %>
<script
defer
data-api={PlausibleWeb.Dogfood.api_destination()}
data-domain={PlausibleWeb.Dogfood.domain(@conn)}
src={PlausibleWeb.Dogfood.script_url()}
>
</script>
<script>
window.plausible = window.plausible || function() { (window.plausible.q = window.plausible.q || []).push(arguments) }
<%= if @conn.assigns[:dogfood_page_path] do %>
const pageUrl = '<%= Path.join(plausible_url(), @conn.assigns[:dogfood_page_path]) %>'
<% else %>
const pageUrl = window.location.href
<% end %>
plausible('pageview', {
u: pageUrl,
props: {
logged_in: <%= is_map(@conn.assigns[:current_user]) %>,
theme: '<%= if @conn.assigns[:current_user], do: @conn.assigns[:current_user].theme, else: "system" %>',
browser_language: navigator.language || navigator.userLanguage
}
})
</script>
<% end %>
<% end %>