John Davidson

php - Facebook CAPI PageView Event Missing Some Deduplication Parameters Parameter

0 comments
Message:


I have two problems with Facebook CAPI. I'm using facebook php business sdk


PageView Event Missing Some Deduplication Parameters Parameter


It's showing in every event in Event Manager (PageView, ViewContent, Lead) and I don't know why I haven't dedupi keys shown with CAPI in View Details, but It appears in Test mode. Example:



Code:


if(!isset($_COOKIE['USERID']) || empty($_COOKIE['USERID'])){
$externalId = FacebookCapiSettings::getExternalId();
setcookie('USERID', $externalId, time()+14*24*3600);
$_COOKIE['USERID'] = $externalId;
}

$access_token = FacebookCapiSettings::getAccessToken();
$pixel_id = FacebookCapiSettings::getPixelId();

$api = Api::init(null, null, $access_token);
$api->setLogger(new CurlLogger());
$user_data = (new UserData())
// It is recommended to send Client IP and User Agent for Conversions API Events.
->setClientIpAddress($_SERVER['REMOTE_ADDR'])
->setClientUserAgent($_SERVER['HTTP_USER_AGENT'])
->setFbc($_COOKIE['_fbc'])
->setExternalId($_COOKIE['USERID'])
->setFbp($_COOKIE['_fbp']);

$eventSourceUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

$event = (new Event())
->setEventName('PageView')
->setEventTime(time())
->setEventSourceUrl($eventSourceUrl)
->setUserData($user_data)
->setEventId(FacebookCapiPageView::getEventId())
->setActionSource(ActionSource::WEBSITE);

$events = array();
array_push($events, $event);

$request = (new EventRequest($pixel_id))
->setTestEventCode(FacebookCapiSettings::getTestKey())
->setEvents($events);
$response = $request->execute();


  • Event ID as setEventId(FacebookCapiPageView::getEventId())

  • External ID as setExternalId($_COOKIE['USERID'])

  • FBP as setFbp($_COOKIE['_fbp']);


Server Sending Invalid External ID Parameter.


It's showing only with PageView Event Matching


Code:


        <!-- Facebook Pixel -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq( 'init', '<?php echo FacebookCapiSettings::getPixelId(); ?>', {'external_id': '<?php echo $_COOKIE['USERID']; ?>'<?php echo $userDataString; ?>} );
fbq( 'track', 'PageView', {}, {eventID: '<?php echo FacebookCapiPageView::getEventId(); ?>'} );
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=<?php echo FacebookCapiSettings::getPixelId(); ?>&ev=PageView&noscript=1"
/></noscript>
<!--/ Facebook Pixel -->



What I did wrong and how I could repair my errors in Facebook Events Manager?



My Answer:
> I recommend checking the implementation of your deduplication keys in your code. Make sure that you are passing the necessary parameters for deduplication in your PageView event.

> Additionally, ensure that your deduplication parameters are correctly set up in your Facebook Business Manager settings. Double-check that the deduplication keys are properly configured for your pixel.

> If the deduplication keys are showing in Test mode but not in live events, it could be a configuration issue. Review your code and settings to ensure that everything is set up correctly for live events to capture the deduplication parameters.

> If you continue to experience issues, consider reaching out to Facebook support for further assistance with troubleshooting the problem.

Rate this post

3 of 5 based on 1868 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us