Skip to content

Conversation

@joe-ayoub-segment
Copy link
Contributor

@joe-ayoub-segment joe-ayoub-segment commented Oct 29, 2025

Enhancements to Google Enhanced Conversions.

  1. Add new field to collect IP address.
  2. Adds new session_attributes_encoded field
  3. Adds new session_attributes_key_value_pairs field

Testing

Unit tests updated.

Tested in staging - though without credentials

Confirmed payload is correct with team at Google.

Staging tests

image

Request:

{
  "body": {
    "conversions": [
      {
        "cartData": {
          "items": null
        },
        "conversionAction": "customers/8414231766/conversionActions/576882637",
        "conversionDateTime": "2023-12-10 04:08:31+00:00",
        "sessionAttributesKeyValuePairs": {
          "keyValuePairs": [
            {
              "sessionAttributeKey": "gad_source",
              "sessionAttributeValue": "test source"
            },
            {
              "sessionAttributeKey": "gad_campaignid",
              "sessionAttributeValue": "test campaign id"
            },
            {
              "sessionAttributeKey": "landing_page_url",
              "sessionAttributeValue": "https://app.segment.build/joe-ayoub-segment-stage"
            },
            {
              "sessionAttributeKey": "session_start_time_usec",
              "sessionAttributeValue": "1702181311905000"
            }
          ]
        },
        "userIdentifiers": null,
        "userIpAddress": "78.158.156.119"
      }
    ],
    "partialFailure": true
  },
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "gzip,deflate",
    "Authorization": "REDACTED",
    "Content-Length": "662",
    "Content-Type": "application/json",
    "Developer-Token": "REDACTED",
    "Host": "googleads.googleapis.com",
    "User-Agent": "REDACTED"
  }
}

response

{
  "body": {
    "jobId": "6477866775090568426",
    "results": [
      {
        "conversionAction": "customers/8414231766/conversionActions/576882637",
        "conversionDateTime": "2023-12-10 04:08:31+00:00"
      }
    ]
  },
  "headers": {
    "Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000",
    "Content-Encoding": "gzip",
    "Content-Type": "application/json; charset=UTF-8",
    "Date": "Tue, 02 Dec 2025 13:04:37 GMT",
    "Request-Id": "o5zO-_XRqkDn-Bl7x1W2Dg",
    "Server": "ESF",
    "Transfer-Encoding": "chunked",
    "Vary": "Origin, X-Origin, Referer",
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "SAMEORIGIN",
    "X-Xss-Protection": "0"
  }
}

@joe-ayoub-segment joe-ayoub-segment marked this pull request as ready for review October 30, 2025 12:34
@joe-ayoub-segment joe-ayoub-segment requested a review from a team as a code owner October 30, 2025 12:34
sayan-das-in
sayan-das-in previously approved these changes Oct 30, 2025
@joe-ayoub-segment joe-ayoub-segment changed the title STRATCONN-6214 - [Google Ads Conversions] - Enhancements STRATCONN-6214 - [Google Enhanced Conversions] - Enhancements Oct 31, 2025
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.06%. Comparing base (9ed58fa) to head (66f62a9).
⚠️ Report is 63 commits behind head on main.

Files with missing lines Patch % Lines
...tinations/google-enhanced-conversions/functions.ts 77.77% 3 Missing and 1 partial ⚠️
...nhanced-conversions/uploadClickConversion/index.ts 75.00% 0 Missing and 2 partials ⚠️
...hanced-conversions/uploadClickConversion2/index.ts 75.00% 0 Missing and 2 partials ⚠️

❌ Your patch status has failed because the patch coverage (76.47%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3376      +/-   ##
==========================================
+ Coverage   80.00%   80.06%   +0.06%     
==========================================
  Files        1211     1226      +15     
  Lines       22353    22767     +414     
  Branches     4411     4526     +115     
==========================================
+ Hits        17884    18229     +345     
- Misses       3689     3701      +12     
- Partials      780      837      +57     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds enhancements to the Google Enhanced Conversions destination to improve conversion tracking capabilities. The changes add three new fields to capture additional session and user data.

Key changes:

  • Added user_ip_address field to capture the IP address of users who initiated conversions
  • Added session_attributes_encoded field with a default mapping
  • Added session_attributes_key_value_pairs field as an alternative to the encoded field for offline conversions

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uploadClickConversion2/index.ts Added three new input fields and updated request object construction to conditionally include the new fields
uploadClickConversion/index.ts Applied the same field additions and logic as uploadClickConversion2 for consistency
uploadClickConversion2/generated-types.ts Updated TypeScript types to include the new fields in the Payload interface
uploadClickConversion/generated-types.ts Updated TypeScript types to match uploadClickConversion2
types.ts Added KeyValuePairList and KeyValueItem types and updated ClickConversionRequestObjectInterface
functions.ts Added timestampToEpochMicroseconds and getSessionAttributesKeyValuePairs helper functions
__tests__/uploadClickConversion2.test.ts Updated test snapshots and added new test for sessionAttributesKeyValuePairs
__tests__/uploadClickConversion.test.ts Updated test snapshots and added new test for sessionAttributesKeyValuePairs
__tests__/functions.test.ts Added tests for the new timestampToEpochMicroseconds function

Comment on lines +361 to 363
const { session_attributes_encoded, user_ip_address } = payload

const request_object: ClickConversionRequestObjectInterface = {
Copy link

Copilot AI Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] For consistency with the codebase, consider whether the destructuring of session_attributes_encoded and user_ip_address should occur inline within the spread operators where they're used (lines 369-371), rather than as separate variable declarations. This would avoid creating intermediate variables that are only used once and make the intent clearer that these are conditional includes.

Copilot uses AI. Check for mistakes.
@joe-ayoub-segment joe-ayoub-segment merged commit 480c282 into main Dec 9, 2025
14 of 15 checks passed
@joe-ayoub-segment joe-ayoub-segment deleted the gads-conversions-enhancements branch December 9, 2025 12:39
@joe-ayoub-segment
Copy link
Contributor Author

deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants