Last active
January 9, 2024 08:59
-
-
Save iosiuk/9d66b0f25a3b16958aff648c77c5e542 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import time | |
from facebook_business.adobjects.serverside.event import Event | |
from facebook_business.adobjects.serverside.event_request import EventRequest | |
from facebook_business.adobjects.serverside.user_data import UserData | |
from facebook_business.adobjects.serverside.custom_data import CustomData | |
from facebook_business.adobjects.serverside.action_source import ActionSource | |
from facebook_business.api import FacebookAdsApi | |
access_token = '****************************************************************************************************' | |
pixel_id = '**********************' | |
FacebookAdsApi.init(access_token=access_token) | |
user_data = UserData( | |
client_ip_address = '91.166.107.1', | |
client_user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36', | |
fbc='fb.2.1583506521913.IwAR1EAVRZqLEbZ2T27j5zbooWbzuf_u6PsdSVno-Cvk-sfWpgoVFCUBzpoFQ', | |
fbp='fb.2.1571112275753.247624567' | |
) | |
custom_data = CustomData( | |
currency='usd', | |
value=1.0 | |
) | |
event = Event( | |
event_name='Purchase', | |
event_time=int(time.time()), | |
action_source = ActionSource.OTHER | |
user_data=user_data, | |
custom_data=custom_data, | |
) | |
events = [event] | |
event_request = EventRequest( | |
events=events, | |
# test_event_code = 'TEST47839', | |
pixel_id=pixel_id) | |
event_response = event_request.execute() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment