rudderlabs / rudder-sdk-js

JavaScript SDK for RudderStack - the Customer Data Platform for Developers.
https://www.rudderstack.com
Other
141 stars 81 forks source link

Currency not include in Facebook Pixel InitiateCheckout event #273

Closed alan-cooney closed 2 years ago

alan-cooney commented 3 years ago

When you set currency like this, it is not sent in the FB InitiateCheckout event:

  rudderAnalytics.track('Checkout Started', {
    //...
    currency: "GBP"
  });

Using debug mode on a development version of our site, the tracking event logs with currency in it, so it appears to be an issue with the integration:

{
  "message": {
    "channel": "web",
    "context": {
      "app": {
        "build": "1.0.0",
        "name": "RudderLabs JavaScript SDK",
        "namespace": "com.rudderlabs.javascript",
        "version": "1.0.16"
      },
      "traits": {
 // Removed
      },
      "library": {
        "name": "RudderLabs JavaScript SDK",
        "version": "1.0.16"
      },
      "userAgent": "", // Removed
      "locale": "en-GB",
      "os": {
        "name": "",
        "version": ""
      },
      "screen": {
        "density": 3
      },
      "device": null,
      "network": null,
      "campaign": {},
      "page": {
        "path": "/book/group_UUID",
        "referrer": "http://localhost:3000/book/group_UUID",
        "referring_domain": "localhost:3000",
        "search": "",
        "title": "Trip Reservation - Trip Title - Skyhook Adventure",
        "url": "http://localhost:3000/book/group_UUID"
      }
    },
    "type": "track",
    "action": null,
    "messageId": "fb1f194d-205c-436d-b9aa-08b024987c81",
    "originalTimestamp": "2021-07-20T09:26:39.129Z",
    "anonymousId": "aa55548e-2e35-4ed5-a3b9-f9bddbe3a2dd",
    "userId": "user_ADMIN",
    "event": "Checkout Started",
    "properties": {
      "value": 12.8,
      "revenue": 125,
      "currency": "GBP",
      "products": [
        {
          "product_id": "trip_UUID",
          "sku": "group_UUID",
          "name": "Trip Title",
          "brand": "Host Name",
          "variant": "2020-01-01T00:00:00.000Z",
          "price": 125,
          "url": "https://dev.skyhookadventure.com/trips/url-slug",
          "image_url": "https://dev-skyhook.imgix.net/key.jpg?ixlib=react-9.1.1"
        }
      ]
    },
    "integrations": {
      "All": true
    },
    "user_properties": null
  }
}

Here is the output from Facebook pixel debugger (note the content_ids and contents are also not sent despite being included in the event):

CUSTOM PARAMETERS SENT
content_type: ["product"]
content_ids: [null]
value: 125.00
contents: [{}]
num_items: 1
ruchiramoitra commented 3 years ago

@alan-cooney Hi. I tried testing the same payload but these are getting set...

Can you give more context...

ruchiramoitra commented 3 years ago
Screenshot 2021-07-20 at 4 02 24 PM
alan-cooney commented 3 years ago

Hi @ruchiramoitra,

I've updated to 1.0.17 (was on .16) and it is now sending the default currency of USD rather than nothing (i.e. still not picking up the GBP). My setup is:

{
    "blacklistPiiProperties": [
        {
            "blacklistPiiProperties": "",
            "blacklistPiiHash": false
        }
    ],
    "categoryToContent": [
        {
            "from": "",
            "to": ""
        }
    ],
    "pixelId": "394675804771668",
    "eventsToEvents": [
        {
            "from": "",
            "to": "Purchase"
        }
    ],
    "eventCustomProperties": [
        {
            "eventCustomProperties": "messageId"
        },
        {
            "eventCustomProperties": ""
        }
    ],
    "valueFieldIdentifier": "properties.price",
    "advancedMapping": true,
    "whitelistPiiProperties": [
        {
            "whitelistPiiProperties": ""
        }
    ]
}
alan-cooney commented 3 years ago

Interestingly if I log inside the rudder-sdk-js module directly, within the facebook pixel integration track function, some key properties are missing (including currency):

{
    "value": 12.8,
    "revenue": 125,
    "products": [
        {
            "sku": "group_UUID",
            "url": "https://dev.skyhookadventure.com/trips/url-slug",
            "image_url": "https://dev-skyhook.imgix.net/key.jpg?ixlib=react-9.1.1"
        }
    ]
}
alan-cooney commented 3 years ago

Okay disabling GA4 integration solves the issue - which suggests that the GA4 integration is mutating the track event properties?

alan-cooney commented 3 years ago

Found the culprit - creating a PR now:

// eslint-disable-next-line no-param-reassign
        delete props[key];
alan-cooney commented 3 years ago

274

saikumarrs commented 2 years ago

PR #274 has been merged. Hence, closing this issue.