From f28effc57c5c48149669c7409284051f63029063 Mon Sep 17 00:00:00 2001 From: Sanne de Vries Date: Wed, 26 Nov 2025 17:19:34 +0100 Subject: [PATCH] Add static custom property UI to goal settings form --- lib/plausible_web/live/goal_settings/form.ex | 67 ++++++++++++++++---- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/lib/plausible_web/live/goal_settings/form.ex b/lib/plausible_web/live/goal_settings/form.ex index adf38bb971a0..2cdb7ed26af4 100644 --- a/lib/plausible_web/live/goal_settings/form.ex +++ b/lib/plausible_web/live/goal_settings/form.ex @@ -165,7 +165,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do def pageview_fields(assigns) do ~H""" -
+
Pageview goals allow you to measure how many people visit a specific page or section of your site. Learn more in <.styled_link href="https://plausible.io/docs/pageview-goals" @@ -204,6 +204,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do x-data="{ firstFocus: true }" x-on:focus="if (firstFocus) { $el.select(); firstFocus = false; }" /> + + <.custom_property_section suffix={@suffix} />
""" end @@ -222,6 +224,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do scrollThreshold: '90', pagePath: '', displayName: '', + addCustomProperty: false, updateDisplayName() { if (this.scrollThreshold && this.pagePath) { this.displayName = `Scroll ${this.scrollThreshold}% on ${this.pagePath}` @@ -235,6 +238,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do scrollThreshold: '#{assigns.goal.scroll_threshold}', pagePath: '#{assigns.goal.page_path}', displayName: '#{assigns.goal.display_name}', + addCustomProperty: false, updateDisplayName() {} } """ @@ -299,6 +303,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do x-data="{ firstFocus: true }" x-on:focus="if (firstFocus) { $el.select(); firstFocus = false; }" /> + + <.custom_property_section suffix={@suffix} />
""" end @@ -317,7 +323,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do def custom_event_fields(assigns) do ~H""" -
+
Custom Events are not tracked by default - you have to configure them on your site to be sent to Plausible. See examples and learn more in <.styled_link @@ -364,6 +370,8 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do />
+ <.custom_property_section suffix={@suffix} /> + <%= if ee?() and Plausible.Sites.regular?(@site) and not editing_non_revenue_goal?(assigns) do %> <.revenue_goal_settings f={@f} @@ -382,6 +390,43 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do """ end + attr(:suffix, :string, required: true) + + def custom_property_section(assigns) do + ~H""" +
+ + Add custom property + + <.toggle_switch + id="add-custom-property" + id_suffix={@suffix} + js_active_var="addCustomProperty" + /> +
+ +
+ <.live_component + id={"property_input_#{@suffix}"} + submit_name="goal[property]" + placeholder="Select property" + module={ComboBox} + suggest_fun={fn _input, _options -> [] end} + creatable + /> + is + <.live_component + id={"value_input_#{@suffix}"} + submit_name="goal[value]" + placeholder="Select value" + module={ComboBox} + suggest_fun={fn _input, _options -> [] end} + creatable + /> +
+ """ + end + def revenue_goal_settings(assigns) do js_data = Jason.encode!(%{ @@ -394,7 +439,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do ~H"""
<%= if is_nil(@goal) do %> -
+
<.revenue_toggle {assigns} />
<% else %> @@ -515,15 +560,9 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do />.
-
- +
Enable revenue tracking +
"""