Coder Social home page Coder Social logo

Comments (6)

mikehardy avatar mikehardy commented on June 25, 2024

Interesting. So how did it go when you built the string yourself with the correct single-quotes etc then sent that in as the string argument for ContentId?

from react-native-fbsdk-next.

rukmanary avatar rukmanary commented on June 25, 2024

Well, I will tell you more details...

I tried something like this:

const content_ids = [];
content_ids.push(`${itemCartList[i]?.product_id}`);

const ids = `[${content_ids.join(',')}]`;

AppEventsLogger.logEvent('InitiatedCheckout', 10000, {
      [AppEventsLogger.AppEventParams.ContentID]: ids,
      [AppEventsLogger.AppEventParams.ContentType]: 'product',
      [AppEventsLogger.AppEventParams.Currency]: 'IDR',
      [AppEventsLogger.AppEventParams.NumItems]: parseInt(2),
      [AppEventsLogger.AppEventParams.Content]: JSON.stringify(// * some items' information (array) * // ),
})

it does logged in Test Events because ids is a String. But it takes some times, maybe a day or more to see the result in Catalog Conversions

I track the code and found that the Facebook Android SDK (AppEvent.java) is throwing an exception for datatypes other than String and Number:

Screen Shot 2021-05-25 at 15 16 53

as mentioned here https://developers.facebook.com/docs/app-events/getting-started-app-events-android

Screen Shot 2021-05-25 at 15 23 55

Honestly, I'm a little bit confuse with the documentation. It says here https://www.facebook.com/business/help/892811264497819 that the required app events for Dynamic Ads are:
Screen Shot 2021-05-25 at 15 33 58

My app can purchased more than one item at once, so it has multiple contentID. But, the SDK is not allowing us to send an array.

In Facebook Commerce Manager, my Retargeted Ads is 0%:
Screen Shot 2021-05-25 at 15 37 34

In How to Fix it section, I just did the number one solution and waiting for the result for single contentID.
I click Learn More and this appears:
Screen Shot 2021-05-25 at 15 47 35

I already make sure everything in the screenshot above. Now I scroll down and come to this part:

Screen Shot 2021-05-25 at 15 48 02

or you can read it from this https://business.facebook.com/business/help/644889989181423?id=725943027795860 it's exactly the same.

It said "website", now I may change the question, is multiple contentID only possible for website (for now)? Because the article said that we need to send content_ids with 's'. And it can be String or Array data type. But, technically, in mobile apps we cannot send an array.

from react-native-fbsdk-next.

mikehardy avatar mikehardy commented on June 25, 2024

const ids = [${content_ids.join(',')}];

Should maybe be

const ids = ['${content_ids.join('','')}'];

(note the single-quotes - to match what they request, I think)

Honestly this is way out of my depth, but it still seems like the content ids are not sent exactly as they expect, with each id being a number inside single quotes, with multiple ids separated by commas

from react-native-fbsdk-next.

rukmanary avatar rukmanary commented on June 25, 2024

I already done that. But it turns out even a single id doesn't match too. I already follow the instruction in this library, Event Manager received all of my events. I also made some catalog, input the products and write down the content ID the same value as I sent from events. But when it comes to the Commerce Manager, Mobile App Conversions with Matched Content IDs shows me 0% matches to contentID.

I can't figure out what's wrong because l just follow the instruction to initializedSDK and then we good to go. I just need AppEvent feature for Fb Pixel and from this example https://github.com/thebergamo/react-native-fbsdk-next#app-events-1 there's no other setup. So, I don't know what's wrong?

Do you have any reference or can you confirm that this is only happens to me and the others app works fine?

from react-native-fbsdk-next.

mikehardy avatar mikehardy commented on June 25, 2024

This is not a use case for me so I have never coded to these APIs or used them and am not planning too - which means unfortunately I think I've helped you as much as I can

from react-native-fbsdk-next.

rukmanary avatar rukmanary commented on June 25, 2024

Anyway, I solved this recently... As I mention above, I send the event like this:

const content_ids = [];
content_ids.push(`${itemCartList[i]?.product_id}`);

const ids = `[${content_ids.join(',')}]`;

AppEventsLogger.logEvent('InitiatedCheckout', 10000, {
      [AppEventsLogger.AppEventParams.ContentID]: ids,
      [AppEventsLogger.AppEventParams.ContentType]: 'product',
      [AppEventsLogger.AppEventParams.Currency]: 'IDR',
      [AppEventsLogger.AppEventParams.NumItems]: parseInt(2),
      [AppEventsLogger.AppEventParams.Content]: JSON.stringify(// * some items' information (array) * // ),
      // some custom params
})

But then I tried to send a minimum parameters as the facebook documentation said and modify my code:

    const content_ids = [];
    content_ids.push(`${itemCartList[i]?.product_id}`);
    const ids = content_ids?.length > 1
                   ? `[${content_ids.join(',')}]`
                   : content_ids[0];

AppEventsLogger.logEvent('InitiatedCheckout', 10000, {
      [AppEventsLogger.AppEventParams.ContentID]: ids,
      [AppEventsLogger.AppEventParams.ContentType]: 'product',
      [AppEventsLogger.AppEventParams.Currency]: 'IDR',
      [AppEventsLogger.AppEventParams.NumItems]: parseInt(2),
})

And it finally works, the data now can be retargeted.

I have 2 suspects, but I don't have any prove yet:

  1. Dynamic Ads Event cannot take custom params
  2. Double quote in JSON.stringify output

But I guess suspect number 2 is the real problem since they mention in the documentation to send contentID in single quote. But what makes me confuse is the documentation give me an example how to write AppEventsLogger.AppEventParams.Content param as a JSON. So I simply use JSON.stringify...
Screen Shot 2021-06-28 at 11 17 27

In conclusion, the solution for me to send single or multiple contentID for Dynamic Ads for Mobile Apps is to send a minimum parameters just like the example in documentation. For my case in retail/e-Commerce, I follow this: https://developers.facebook.com/docs/app-events/best-practices/ecom-and-retail

from react-native-fbsdk-next.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.