Facebook API Integration

Need help? Please give a detailed explanation of your problem.
Post Reply
Trannum3487
Posts: 116
meble kuchenne Mikołów Knurów Czechowice-Dziedzice
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Facebook API Integration

Post by Trannum3487 »

Greetings,
For image sun we have integrated Conversion API and want to manually add Facebook pixel script instead of allowing APWTs to add pixel script.
For that, I have removed Facebook Pixel Id from Administrator however the script is still there when I view the source of this Landing page https://www.imagesunlakeland.com/.

Earlier even the system was not saving blank value for Facebook Pixel ID. Somehow it was saved but the script is still in view source. I have tried switching browsers and also cleared cache and disabling cache.

For more details, I have
<?
HeadIncludes();
print $headadd;
?>

this code is in No Theme Header Template.
and also we are using a CURL request for the setup of Conversion API and that code is in No Footer Template.
Thanks
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

Here is a screenshot of what we are seeing:
Screenshot from 2022-01-03 14-57-47.png
Screenshot from 2022-01-03 14-57-47.png (166.56 KiB) Viewed 1867 times

Can you provide more information about your request?
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Thanks for considering my request and checking this. yesterday, it was visible on view source, but not today. Thank you a lot!

Now, I am facing one more issue with the same website.

We have added manual PHP script code for integrating Facebook Conversion API because of the ios14 update where the Facebook Pixel script does not work. I am using the CURL request for integartion. Earlier the code was working but since yesterday, it is showing me

$ip_address = $ **PHP CODE IS NOT ALLOWED HERE {DMK-00-39}** ['REMOTE_ADDR'];

however, I wrote

$ip_address = $_SERVER['REMOTE_ADDR'];

While debugging I noticed even when I write only the below statement in "No theme Footer", it does not work at all. Can you guide me, please?

print_r($_SERVER);


Even when I write below two statements in "No theme Header" it stops the whole website.

echo $url = 'https://graph.facebook.com/v12.0/840302 ... os0JKzZBHi';

$ch = curl_init($url);

I am not sure why this is happening as earlier the code was working and I was receiving a response from my CURL request. Now each statement is causing an error.



Below is the code I have for API setup which I have removed from "No theme Footer" as it is creating the problem.

<?php

// API URL
$url = 'https://graph.facebook.com/v12.0/840302 ... os0JKzZBHi';

// Create a new cURL resource
$ch = curl_init($url);

$unix_timestamp = time();

// Setup request to send json via POST


$ip_address = $_SERVER['REMOTE_ADDR'];

$request_data = '{
"data": "[\n {\n \"event_name\": \"PageView\",\n \"event_time\": '.$unix_timestamp.',\n \"action_source\": \"website\",\n \"user_data\": {\n \"client_ip_address\": \"'.$ip_address.'\" } \n }\n]"

}';


// Attach encoded JSON string to the POST fields
setopt($ch, CURLOPT_POSTFIELDS, $request_data);

// Set the content type to application/json
setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

// Return response instead of outputting
setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the POST request


$result = curl_exec($ch);
$err = curl_error($ch);


echo "<pre>"; print_r($result); echo "</pre>";

// Close cURL resource
curl_close($ch);

?>

How I can make my code to work back as it was working earlier?
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

In an effort to keep the AllProWebTools platform secured. Server-side programming is not allowed on the platform. With the release of version 5.73, additional features were added to alert users of this policy - this is why you are seeing the message: **PHP CODE IS NOT ALLOWED HERE

We do accept requests for additional functionality to be added under the "Suggestions and feature requests" area here: https://www.allprowebtools.com/forum/viewforum.php?f=4

Attention is given to the features most requested and upvoted by the users of AllProWebTools. If your request is not upvoted by other users, we can provide you with a custom build quote to add the requested functionality. In many cases the quote is a one-time investment of less than $100 - but this varies on the level of complexity of the request. Most new features can be added within 30 days, but again this varies based on the level of complexity.

We encourage you to post your request and request a quote.
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Hi Dave,

Can you please provide the quote and also confirm how it will work as we want "Facebook Conversion API" to be integrated for all our clients who are using Facebook Pixel Code?

Thanks
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

Can you provide more details about the new functionality you are proposing? Some example questions would be:

What data would you like to capture?
What actions will trigger this functionality?
How would you like the data delivered or displayed?

If you have already written code or have code examples that will also be helpful in understanding your request.
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Hi Dave :)

Below attached link has all information about How the Conversions API works and how to use it.
https://www.facebook.com/business/help/ ... 9032317965

Another attached link is for the steps to the integration of Facebook conversion API.
https://developers.facebook.com/docs/ma ... sions-api/

Our only purpose is to capture the "PageView" events like Facebook pixel code does.

Thanks
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

1 - If your goal is to capture pageviews, why is the facebook pixel insufficient for your needs?
2 - How will this integration be different?
3 - What additional data will this collect that is not available with the facebook pixel?
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Due to the 14.5 ios update, Facebook advertising and other advertising platforms are getting destroyed. Which means we can lose all our data and all our tracking ability. Because Facebook pixel code works with browser and ios 14.5 has an option for the operators to block the browser tracking. Due to that, we can lose tracking data.

"Facebook Conversion API" is an alternative to this and it works on the Server, not on the browser.

That is why to save our data from getting lose we need to integrate "Facebook conversion API" for all our clients.


Thanks
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Greetings,

Below is the code for Conversion API. Let me know if anything is required from my side.

<?php

// API URL
$url = 'https://graph.facebook.com/v12.0/840302 ... os0JKzZBHi';

// Create a new cURL resource
$ch = curl_init($url);

$unix_timestamp = time();

// Setup request to send json via POST

$ip_address = $_SERVER['REMOTE_ADDR'];

$request_data = '{
"data": "[\n {\n \"event_name\": \"PageView\",\n \"event_time\": '.$unix_timestamp.',\n \"action_source\": \"website\",\n \"user_data\": {\n \"client_ip_address\": \"'.$ip_address.'\" } \n }\n]"
}';

// Attach encoded JSON string to the POST fields
setopt($ch, CURLOPT_POSTFIELDS, $request_data);

// Set the content type to application/json
setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

// Return response instead of outputting
setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Execute the POST request

$result = curl_exec($ch);
$err = curl_error($ch);

echo "<pre>"; print_r($result); echo "</pre>";

// Close cURL resource
curl_close($ch);

?>
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

The Facebook API has been installed.

You can access it from the "Settings" menu and then "Integrations".

On the integrations page, you can enter the Facebook API Token in the box labeled "Facebook API Token"
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

We have added a Facebook API token for Install ID: 3889
and tried to observe if we are receiving responses. but we are not seeing any conversions in APWT.

Is there anything else that needs to be done? Can you please check why still is not working?
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Trannum3487 »

Uers are clicking on Facebook ads, visiting landing pages, and filling out signup boxes becoming leads. And these leads are not reported in the Facebook ads manager.
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Remove Facebook Pixel Script and add manual in No Theme Header

Post by Dave »

Please go to the Facebook account to obtain the URL to use for this account. It will look similar to this:

Code: Select all

https://graph.facebook.com/v12.0/840302306488245/events?access_token=XXXX
Please paste the complete link in this forum.
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Facebook API Integration

Post by Dave »

I have pulled the logs from today.
AllProWebTools account 3889 sent the the following events to the Facebook API and received the following response codes from Facebook which indicate that the data was received correctly by Facebook:

resulted with {"events_received":1,"messages":[],"fbtrace_id":"A-2xj4UUFKRzY2epWlEh2JQ"} at 2022-03-15 17:39:55 EST
resulted with {"events_received":1,"messages":[],"fbtrace_id":"A4NYMTNMiYj2MHpyhQ_HGeG"} at 2022-03-15 17:24:07 EST
Trannum3487
Posts: 116
Joined: Mon Apr 19, 2021 8:27 am
Website: www.scottcoxconsulting.com

Re: Facebook API Integration

Post by Trannum3487 »

But No result is showing in the Conversion Ad on Facebook.
unnamed (5).png
unnamed (5).png (55.76 KiB) Viewed 1578 times
But in the APWT the results are showing
unnamed (4).png
unnamed (4).png (6.96 KiB) Viewed 1578 times
please check the attached screenshots for reference.

Thank you
User avatar
Dave
Support Team
Support Team
Posts: 1221
Joined: Wed May 11, 2011 10:30 am
Website: www.allprowebtools.com
Contact:

Re: Facebook API Integration

Post by Dave »

You can see a complete and up-to-date record of all of the hits that have been sent to Facebook and the confirmation codes here:

https://www.mailinator.com/

enter the mailbox name: apwtfbapi

If Facebook is returning authorization codes, that indicates that everything is correct on the AllProWebTools side.

Please file a support request with Facebook and provide them with the times, ip addresses, and confirmation codes so they can assist you further. All of this information is provided in the log located at mailinator.com

required.sup:129
Post Reply