When we create a Custom Conversion with FB Graph API, we can define the event
name param. I’m trying to find how can I get first my Custom Events, and then select some custom event to parse to event
name.
How can I do it?
Take a look at Custom Conversions docs: https://developers.facebook.com/docs/marketing-api/reference/custom-conversion/v17.0
Question posted in Facebook API
The official documentation for the Facebook APIs can be found here.
The official documentation for the Facebook APIs can be found here.
2
Answers
My own solution: I used the Ads Pixel Stats endpoint, that you can see here: https://developers.facebook.com/docs/marketing-api/reference/ads-pixel/stats/v17.0
Basically, I made a request to
/{ads-pixel-id}/stats
endpoint by passing theaggregation
param withevent_total_counts
value:https://graph.facebook.com/v17.0/{ads-pixel-id}/stats?aggregation=event_total_counts
That will returns a list of active events (custom and standard) for the pixel with a count of occurrences. Do you can also parse another params, as you can see in the documentation above.
To retrieve your Custom Conversions and select specific events to parse the event name, you can use the Facebook Marketing API. Here’s how you can do it using Python and the
requests
library:First, you need to make a GET request to retrieve your Custom Conversions. You will need to provide your Access Token and Ad Account ID in the request URL.
This will give you a list of your Custom Conversions, including the event names associated with each conversion.
Now that you have the list of Custom Conversions, you can select a specific conversion and parse the event name. Let’s say you want to select the first Custom Conversion:
In this example,
event_name
contains the name of the selected Custom Conversion event.Make sure to handle errors and edge cases appropriately in your code, and also consider pagination if you have a large number of Custom Conversions.
Please note that you need to have the necessary permissions and a valid Access Token to access your Custom Conversions data through the Facebook Marketing API.