Skip to content

Commit ca78858

Browse files
authored
Custom GA4 measurement protocol url (#1162)
1 parent 79ed9c9 commit ca78858

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

libs/core-functions/src/functions/ga4-destination.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,10 @@ const Ga4Destination: JitsuFunction<AnalyticsServerEvent, Ga4Credentials> = asyn
347347
ctx.log.info(`Ga4: no GA4 event is mapped for event type: ${event.type} ID: ${event.messageId}`);
348348
return;
349349
}
350-
const debug = "";
351-
//const debug = ctx.props.validationMode ? "/debug" : "";
352-
const url = `https://www.google-analytics.com${debug}/mp/collect?${query}`;
350+
351+
const baseUrl = ctx.props.url ?? 'https://www.google-analytics.com/mp/collect';
352+
353+
const url = `${baseUrl}?${query}`;
353354

354355
gaRequest = {
355356
...idPart,

libs/core-functions/src/meta.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ export const Ga4Credentials = z.object({
304304
"The measurement ID associated with a stream.<br/><b>For Web:</b> found in the Google Analytics UI under: " +
305305
"<b>Admin > Data Streams > choose your stream > Measurement ID</b><br/><b>For Apps</b>: the Firebase App ID, found in the Firebase console under: <b>Project Settings > General > Your Apps > App ID</b>"
306306
),
307+
url: z.string().url().describe("Measurement Protocol URL.<br/>Default: <code>https://www.google-analytics.com/mp/collect</code><br/>Default debug url: <code>https://www.google-analytics.com/debug/mp/collect</code>").default('https://www.google-analytics.com/mp/collect'),
307308
events: z.string().optional().default("").describe(eventsParamDescription),
308-
//validationMode: z.boolean().default(false).optional(),
309309
});
310310
export type Ga4Credentials = z.infer<typeof Ga4Credentials>;
311311

webapps/console/lib/schema/destinations.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ export const coreDestinations: DestinationType<any>[] = [
807807
{
808808
id: "ga4",
809809
icon: ga4Icon,
810-
title: "Google Analytics 4",
810+
title: "GA4 (Measurement Protocol)",
811811
tags: "Product Analytics",
812812
connectionOptions: CloudDestinationsConnectionOptions,
813813
credentials: meta.Ga4Credentials,

0 commit comments

Comments
 (0)