Skip to content

Instantly share code, notes, and snippets.

@nicogaspa
Last active July 9, 2019 21:26
Show Gist options
  • Save nicogaspa/0b376887fb12647d880a6b6cf94b6f99 to your computer and use it in GitHub Desktop.
Save nicogaspa/0b376887fb12647d880a6b6cf94b6f99 to your computer and use it in GitHub Desktop.
simple class with function to create an offline event set using facebook python sdk
from facebook_business.adobjects.offlineconversiondataset import OfflineConversionDataSet
from facebook_business.api import FacebookAdsApi
class FacebookService:
def __init__(self):
self.api = FacebookAdsApi.init(app_id='your_app_id', app_secret='your_app_secret',
access_token='your_access_token')
def create_offline_event_set(self, name):
params = {
'enable_auto_assign_to_accounts': True,
'name':'test_event_set',
'description':'this is an example dataset'
}
response = OfflineConversionDataSet().api_create('account_id', params=params)
return response['id'] # This will be the dataset ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment