Skip to content

Commit

Permalink
Update acquisition channel UDF to prioritize display over paid search (
Browse files Browse the repository at this point in the history
…#4818)

* Update acquisition channel UDF to prioritize display over paid search

* Remove migration

Will run this manually together with a backfill, self-hosted will get this for free.

* Add test

---------

Co-authored-by: Karl-Aksel Puulmann <[email protected]>
  • Loading branch information
ukutaht and macobo authored Nov 14, 2024
1 parent b42ab94 commit daa42cb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ CREATE OR REPLACE FUNCTION acquisition_channel_lowered <%= @on_cluster_statement
(referrer_source, utm_medium, utm_campaign, utm_source, click_id_param) ->
multiIf(
acquisition_channel_cross_network(utm_campaign), 'Cross-network',
acquisition_channel_display(utm_medium), 'Display',
acquisition_channel_paid_shopping(referrer_source, utm_medium, utm_campaign), 'Paid Shopping',
acquisition_channel_paid_search(referrer_source, utm_medium, utm_source, click_id_param), 'Paid Search',
acquisition_channel_paid_social(referrer_source, utm_medium, utm_source), 'Paid Social',
acquisition_channel_paid_video(referrer_source, utm_medium, utm_source), 'Paid Video',
acquisition_channel_display(utm_medium), 'Display',
acquisition_channel_paid_medium(utm_medium), 'Paid Other',
acquisition_channel_organic_shopping(referrer_source, utm_campaign), 'Organic Shopping',
acquisition_channel_organic_social(referrer_source, utm_medium), 'Organic Social',
Expand Down
8 changes: 7 additions & 1 deletion test/plausible/ingestion/acquisition_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ defmodule Plausible.Ingestion.AcquisitionTest do
%{referrer_source: "steamcommunity.com", expected: "Organic Social"},
%{referrer_source: "Vkontakte", expected: "Organic Social"},
%{referrer_source: "Threads", expected: "Organic Social"},
%{referrer_source: "Ecosia", expected: "Organic Search"}
%{referrer_source: "Ecosia", expected: "Organic Search"},
%{
referrer_source: "Google",
utm_medium: "display",
click_id_param: "123identifier",
expected: "Display"
}
]

for {test_data, index} <- Enum.with_index(@static_tests, 1) do
Expand Down
18 changes: 18 additions & 0 deletions test/plausible_web/controllers/api/external_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,6 +1554,24 @@ defmodule PlausibleWeb.Api.ExternalControllerTest do
assert session.acquisition_channel == "Display"
end

test "display channel with gclid", %{conn: conn, site: site} do
params = %{
name: "pageview",
url: "http://example.com?utm_medium=display&utm_source=google&gclid=123identifier",
domain: site.domain
}

conn =
conn
|> put_req_header("user-agent", @user_agent)
|> post("/api/event", params)

session = get_created_session(site)

assert response(conn, 202) == "ok"
assert session.acquisition_channel == "Display"
end

test "parses paid other channel", %{conn: conn, site: site} do
params = %{
name: "pageview",
Expand Down

0 comments on commit daa42cb

Please sign in to comment.