Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
124 views
in Technique[技术] by (71.8m points)

javascript - Facebook´s Conversion API Custom Audience

I′m trying to create a Custom Audience on Facebook′s Conversion API following this guide: https://developers.facebook.com/docs/marketing-api/audiences/guides/audience-rules

Ive got my data on a JSON:

       const rule = {
"inclusions": {
    "operator": "or",   // Required. and or or.
    "rules": [{
        "retention_seconds": 3500, //Required.  Integer (in seconds) for the retention window of the audience. Min=1; Max=365 days
        "event_sources": [{
            "id": "<OFFLINE_EVENT_SET_ID>",
            "type": "offline_events"
        }],
    "filter": {
            "operator": "and", // Required. and or or.
            "filters": [{
                    "operator": "=", //If field set to event, must use =.
                    "field": "event", //event
                    "value": "purchase"
                },
                {
                    "operator": ">",
                    "field": "value",
                    "value": "50"
                }
            ]
        }
    }]
}
}

const audienceData = {
      "name": "Customs",
      "rule": rule,
      "access_token": access_token
  }

Pushing it with axios:

 async function CustomAudience(audience) {
    try {
        return await axios.post(`https://graph.facebook.com/${api_version}/${audienceID}/users`, audience);
    } catch (error) {
        console.error(error);
    }
}

customAudience(audienceData);

I know i can do it with offline conversions, (among other things, because it gives me the option on field)

For Store Visits Custom Audiences, use 'event' or store_visit_country.

My question is regarding "retention seconds"

as they are offline conversions, I do not have retention_seconds, and according to the documentation, they are required, and I can not modify my JSON data, as it comes from a CRM.

And when you do a Custom Audience manually, you do not have to specify retention_seconds...

What is the best practice here? Re build a JSON and add a fake retention_seconds seems dirty, but its a required field...

question from:https://stackoverflow.com/questions/65930117/facebook%c2%b4s-conversion-api-custom-audience

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...