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
  • Loading branch information
ukutaht committed Nov 13, 2024
1 parent 9b6961c commit b4b4fe1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Plausible.IngestRepo.Migrations.UpdateAcquisitionChannelUdf do
use Ecto.Migration

def change do
Plausible.DataMigration.AcquisitionChannel.run()
end
end
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 b4b4fe1

Please sign in to comment.