defmodule PlausibleWeb.Live.Installation.Instructions do @moduledoc """ Instruction forms and components for the Installation module """ use PlausibleWeb, :component attr :tracker_script_configuration_form, :map, required: true def manual_instructions(assigns) do ~H""" <.title class="mt-4"> Script installation
Paste this snippet into the <head> section of your site. See our <.styled_link href="https://plausible.io/docs/integration-guides" new_tab={true}> installation guides. Once done, click the button below to verify your installation.
<.snippet_form text={render_snippet(@tracker_script_configuration_form.data)} rows={6} resizable={true} /> <.h2 class="mt-8 text-sm font-medium">Optional measurements <.script_config_control field={@tracker_script_configuration_form[:outbound_links]} label="Outbound links" tooltip="Automatically track clicks on external links. These count towards your billable pageviews." learn_more="https://plausible.io/docs/outbound-link-click-tracking" /> <.script_config_control field={@tracker_script_configuration_form[:file_downloads]} label="File downloads" tooltip="Automatically track file downloads. These count towards your billable pageviews." learn_more="https://plausible.io/docs/file-downloads-tracking" /> <.script_config_control field={@tracker_script_configuration_form[:form_submissions]} label="Form submissions" tooltip="Automatically track form submissions. These count towards your billable pageviews." learn_more="https://plausible.io/docs/form-submissions-tracking" /> <.disclosure> <.disclosure_button class="mt-4 flex items-center group"> <.h2 class="text-sm font-medium">Advanced options <.disclosure_panel> """ end attr :flow, :string, required: true attr :recommended_installation_type, :string, required: true def wordpress_instructions(assigns) do ~H""" <.title class="mt-4"> WordPress installation
We've detected your website is using WordPress. Here's how to integrate Plausible: Using Wordpress? Here's how to integrate Plausible:
<.focus_list> <:item> <.styled_link href="https://plausible.io/wordpress-analytics-plugin" new_tab={true}> Install our WordPress plugin <:item> After activating our plugin, click the button below to verify your installation.
""" end attr :recommended_installation_type, :string, required: true attr :tracker_script_configuration_form, :map, required: true def gtm_instructions(assigns) do ~H""" <.title class="mt-4"> Tag Manager installation
We've detected your website is using Google Tag Manager. Here's how to integrate Plausible: Using Google Tag Manager? Here's how to integrate Plausible:
<.focus_list> <:item> Copy your site's Script ID: <.snippet_form text={@tracker_script_configuration_form.data.id} rows={1} resizable={false} /> <:item> <.styled_link href="https://plausible.io/gtm-template" new_tab={true}> Install the Plausible template in GTM <:item> Paste your Script ID into the template and click the button below to verify your installation.
""" end def npm_instructions(assigns) do ~H""" <.title class="my-4"> NPM installation <.focus_list> <:item> <.styled_link href="https://www.npmjs.com/package/@plausible-analytics/tracker" new_tab={true}> Install @plausible-analytics/tracker NPM package <:item> Once done, click the button below to verify your installation. """ end attr :field, :any, required: true attr :label, :string, required: true attr :tooltip, :string, required: true attr :learn_more, :string, required: true defp script_config_control(assigns) do ~H"""
<.input mt?={false} field={@field} label={@label} type="checkbox" />
<.tooltip sticky?={false}> <:tooltip_content> {@tooltip}
Click to learn more.
""" end defp advanced_option(assigns) do ~H"""
  • {@label}
    <.tooltip sticky?={false}> <:tooltip_content> {@tooltip}
    Click to learn more.
  • """ end defp snippet_form(assigns) do ~H"""
    COPY
    """ end defp render_snippet(tracker_script_configuration) do """ """ end defp tracker_url(tracker_script_configuration) do "#{PlausibleWeb.Endpoint.url()}/js/#{tracker_script_configuration.id}.js" end end