-
Notifications
You must be signed in to change notification settings - Fork 293
STRATCONN-6214 - [Google Enhanced Conversions] - Enhancements #3376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
5c07758
eb0a401
7a2f329
47dcd91
df535f1
44bdde0
9413c42
ad7a88e
a507dd5
fba0bad
0a2bcbb
9c67b87
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -80,7 +80,6 @@ export interface ConversionAdjustmentRequestObjectInterface { | |||||||||||||||||
| userAgent: string | undefined | ||||||||||||||||||
| restatementValue?: RestatementValueInterface | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| export interface ClickConversionRequestObjectInterface { | ||||||||||||||||||
| cartData: CartDataInterface | undefined | ||||||||||||||||||
| consent?: ConsentInterface | ||||||||||||||||||
|
|
@@ -93,11 +92,28 @@ export interface ClickConversionRequestObjectInterface { | |||||||||||||||||
| gclid: string | undefined | ||||||||||||||||||
| gbraid: string | undefined | ||||||||||||||||||
| wbraid: string | undefined | ||||||||||||||||||
| sessionAttributesEncoded: string | undefined | ||||||||||||||||||
| userIpAddress?: string | ||||||||||||||||||
| sessionAttributesEncoded?: string | ||||||||||||||||||
| sessionAttributesKeyValuePairs?: { | ||||||||||||||||||
| keyValuePairs: KeyValuePairList | ||||||||||||||||||
| } | ||||||||||||||||||
| orderId: string | undefined | ||||||||||||||||||
| userIdentifiers: UserIdentifierInterface[] | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| export type KeyValuePairList = Array<KeyValueItem> | ||||||||||||||||||
|
|
||||||||||||||||||
| export type KeyValueItem = { | ||||||||||||||||||
| sessionAttributeKey: | ||||||||||||||||||
| 'gad_source' | ||||||||||||||||||
| | 'gad_campaignid' | ||||||||||||||||||
| | 'landing_page_url' | ||||||||||||||||||
| | 'session_start_time_usec' | ||||||||||||||||||
| | 'landing_page_referrer' | ||||||||||||||||||
| | 'landing_page_user_agent' | ||||||||||||||||||
|
Comment on lines
+107
to
+113
|
||||||||||||||||||
| sessionAttributeKey: | |
| 'gad_source' | |
| | 'gad_campaignid' | |
| | 'landing_page_url' | |
| | 'session_start_time_usec' | |
| | 'landing_page_referrer' | |
| | 'landing_page_user_agent' | |
| sessionAttributeKey: 'gad_source' | 'gad_campaignid' | 'landing_page_url' | 'session_start_time_usec' | 'landing_page_referrer' | 'landing_page_user_agent' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,8 @@ import { | |
| getApiVersion, | ||
| commonEmailValidation, | ||
| getConversionActionDynamicData, | ||
| formatPhone | ||
| formatPhone, | ||
| getSessionAttributesKeyValuePairs | ||
| } from '../functions' | ||
| import { GOOGLE_ENHANCED_CONVERSIONS_BATCH_SIZE } from '../constants' | ||
| import { processHashing } from '../../../lib/hashing-utils' | ||
|
|
@@ -55,11 +56,89 @@ const action: ActionDefinition<Settings, Payload> = { | |
| 'The click identifier for clicks associated with web conversions and originating from iOS devices starting with iOS14.', | ||
| type: 'string' | ||
| }, | ||
| user_ip_address: { | ||
| label: 'User IP Address', | ||
| description: 'The IP address of the user who initiated the conversion.', | ||
| type: 'string', | ||
| default: { | ||
| '@path': '$.context.ip' | ||
| } | ||
| }, | ||
| session_attributes_encoded: { | ||
| label: 'Session Attributes (Encoded)', | ||
| description: | ||
| "A base64url-encoded JSON string containing session attributes collected from the user's browser. This provides additional attribution context if gclid, gbraid, or user identifiers are missing.", | ||
| type: 'string' | ||
| "A base64url-encoded JSON string containing session attributes collected from the user's browser. Provides additional attribution context if gclid, gbraid, or user identifiers are missing. ", | ||
| type: 'string', | ||
| default: { | ||
| '@path': '$.integrations.Google Ads Conversions.session_attributes_encoded' | ||
| } | ||
| }, | ||
| session_attributes_key_value_pairs: { | ||
| label: 'Session Attributes (Key Value Pairs)', | ||
| description: | ||
| "An alternative to the 'Session Attributes (Encoded)' field which can be used for Offline Conversions. If both 'Session Attributes (Encoded)' and 'Session Attributes (Key Value Pairs)' are provided, the encoded field takes precedence.", | ||
| type: 'object', | ||
| additionalProperties: false, | ||
| defaultObjectUI: 'keyvalue', | ||
| properties: { | ||
| gad_source: { | ||
| label: 'GAD Source', | ||
| description: | ||
| "An aggregate parameter served in the URL to identify the source of traffic originating from ads. See [Google's docs](https://support.google.com/google-ads/answer/16193746?sjid=2692215861659291994)", | ||
| type: 'string' | ||
| }, | ||
| gad_campaignid: { | ||
| label: 'GAD Campaign ID', | ||
| description: | ||
| "The ID of the specific ad campaign that drove the ad click. See [Google's docs](https://support.google.com/google-ads/answer/16193746?sjid=2692215861659291994)", | ||
| type: 'string' | ||
| }, | ||
| landing_page_url: { | ||
| label: 'Landing Page URL', | ||
| description: | ||
| 'The full URL of the landing page on your website. This indicates the specific page the user first arrived on.', | ||
| type: 'string' | ||
| }, | ||
| session_start_time_usec: { | ||
| label: 'Session Start Time', | ||
| description: | ||
| "The timestamp of when the user's session began on your website. This helps track the duration of user visits. The format should be a full ISO 8601 string. For example \"2025-11-18T08:52:17.023Z\".", | ||
| type: 'string', | ||
| format: 'date-time' | ||
| }, | ||
| landing_page_referrer: { | ||
| label: 'Landing Page Referrer', | ||
| description: | ||
| "The URL of the webpage that linked the user to your website. This helps understand the traffic sources leading to your site. See [Google's docs](https://support.google.com/google-ads/answer/2382957?sjid=658827203196258052)", | ||
| type: 'string' | ||
| }, | ||
| landing_page_user_agent: { | ||
| label: 'Landing Page User Agent', | ||
| description: | ||
| "A string that identifies the user's browser and operating system. This information can be useful for understanding the technical environment of your users.", | ||
| type: 'string' | ||
| } | ||
| }, | ||
| default: { | ||
| gad_source: { | ||
| '@path': '$.properties.gad_source' | ||
| }, | ||
| gad_campaignid: { | ||
| '@path': '$.properties.gad_campaignid' | ||
| }, | ||
| landing_page_url: { | ||
| '@path': '$.context.page.url' | ||
| }, | ||
| session_start_time_usec: { | ||
| '@path': '$.properties.session_start_time_usec' | ||
| }, | ||
| landing_page_referrer: { | ||
| '@path': '$.context.page.referrer' | ||
| }, | ||
| landing_page_user_agent: { | ||
| '@path': '$.context.userAgent' | ||
| } | ||
| } | ||
| }, | ||
| conversion_timestamp: { | ||
| label: 'Conversion Timestamp', | ||
|
|
@@ -279,13 +358,17 @@ const action: ActionDefinition<Settings, Payload> = { | |
| }) | ||
| } | ||
|
|
||
| const { session_attributes_encoded, user_ip_address } = payload | ||
|
|
||
| const request_object: ClickConversionRequestObjectInterface = { | ||
|
Comment on lines
+361
to
363
|
||
| conversionAction: `customers/${settings.customerId}/conversionActions/${payload.conversion_action}`, | ||
| conversionDateTime: convertTimestamp(payload.conversion_timestamp), | ||
| gclid: payload.gclid, | ||
| gbraid: payload.gbraid, | ||
| wbraid: payload.wbraid, | ||
| sessionAttributesEncoded: payload.session_attributes_encoded, | ||
| ...(user_ip_address ? { userIpAddress: user_ip_address } : {}), | ||
| ...(session_attributes_encoded ? { sessionAttributesEncoded: session_attributes_encoded } : {}), | ||
| ...getSessionAttributesKeyValuePairs(payload), | ||
| orderId: payload.order_id, | ||
| conversionValue: payload.value, | ||
| currencyCode: payload.currency, | ||
|
|
@@ -386,13 +469,17 @@ const action: ActionDefinition<Settings, Payload> = { | |
| }) | ||
| } | ||
|
|
||
| const { session_attributes_encoded, user_ip_address } = payload | ||
|
|
||
| const request_object: ClickConversionRequestObjectInterface = { | ||
| conversionAction: `customers/${customerId}/conversionActions/${payload.conversion_action}`, | ||
| conversionDateTime: convertTimestamp(payload.conversion_timestamp), | ||
| gclid: payload.gclid, | ||
| gbraid: payload.gbraid, | ||
| wbraid: payload.wbraid, | ||
| sessionAttributesEncoded: payload.session_attributes_encoded, | ||
| ...(user_ip_address ? { userIpAddress: user_ip_address } : {}), | ||
| ...(session_attributes_encoded ? { sessionAttributesEncoded: session_attributes_encoded } : {}), | ||
| ...getSessionAttributesKeyValuePairs(payload), | ||
| orderId: payload.order_id, | ||
| conversionValue: payload.value, | ||
| currencyCode: payload.currency, | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after 'if' keyword. According to JavaScript/TypeScript style conventions, there should be a space between 'if' and the opening parenthesis. Change
if(!timestamp)toif (!timestamp).