analytics/lib/plausible_web/templates/layout/_tracking.html.heex
hq1 74675f0cbc
Move dogfooding to full build (#3576)
* Move dogfooding to `extra/`

* Remove unused view functions
2023-12-04 10:30:20 +01:00

28 lines
833 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]) %>
}
})
</script>
<% end %>
<% end %>