A simple project to serve as an endpoint for Facebook advertising pixel pings for development and debugging callouts made to https://www.facebook.com/tr/?id=*******&ev=PageView
.
I created this to test and debug Facebook pixel integration without actually hitting Facebook.
Since the endpoint has to be served from https
, you will need to generate a self signed ssl certificate with the name www.facebook.com
and "Always Trust" it locally. You will still see the browser warning that the site is "Not Secure", but it will work.
The following instructions are based on macOS Sierra
- Open the "Keychain Access" application
- Keychain Access > Certificate Assistant > Create a Certificate...
- Assign Name as "www.facebook.com", Identity Type as "Self Signed Root", Certificate Type as "SSL Server"
- Click "Create", "Continue" and "Done" as required
- Find the newly created certificate in Keychain Access
- Double Click and select "Always Trust" under Trust > When using this certificate. Clost window
- Right Click on the certificate and select "Export ......"
- Save the .p12 file in the same folder as
server.py
- Convert it to the .pem format using the command
openssl pkcs12 -in www.facebook.com.p12 -out www.facebook.com.pem -nodes
vim /private/etc/hosts
Add www.facebook.com
as an alias for 127.0.0.1
127.0.0.1 localhost www.facebook.com
The reason why this works out is because the actual Facebook tag that implements the fbq
function is loaded from connect.facebook.net
, which is not in the hosts file. Hence, the plumbing loades succesfully.
The https://www.facebook.com/tr/
endpoint is used for pinging the pixel, which we are intercepting and simply logging!
On macOS Sierra, I had to make sure
- Firewall was turned off
- The default
https
service was stoppedsudo apachectl stop
sudo python server.py
sudo is required to serve on port 80
Lauch the page you want to test debug and as it loades and pings the Facebook pixel, you will see the query and parameter details on the STDOUT from server.py