diff --git a/lib/plausible_web/live/goal_settings/form.ex b/lib/plausible_web/live/goal_settings/form.ex index 716a7eb99e2a..acf7ee0f746f 100644 --- a/lib/plausible_web/live/goal_settings/form.ex +++ b/lib/plausible_web/live/goal_settings/form.ex @@ -200,7 +200,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. <.styled_link @@ -240,6 +240,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 @@ -258,6 +260,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}` @@ -271,6 +274,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() {} } """ @@ -336,6 +340,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 @@ -354,7 +360,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 @@ -401,6 +407,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} @@ -419,6 +427,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!(%{ @@ -431,7 +476,7 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do ~H"""
<%= if is_nil(@goal) do %> -
+
<.revenue_toggle {assigns} />
<% else %> @@ -552,15 +597,9 @@ defmodule PlausibleWeb.Live.GoalSettings.Form do />.
-
- +
Enable revenue tracking +
"""