Update acquisition channel UDF to prioritize display over paid search (#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 <oxymaccy@gmail.com>
This commit is contained in:
Uku Taht 2024-11-14 18:01:34 +02:00 committed by GitHub
parent b42ab94a14
commit daa42cbc9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 2 deletions

View File

@ -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',

View File

@ -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

View File

@ -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",