in integration/FacebookWordpressNinjaForms.php [42:81]
public static function injectLeadEvent($actions, $form_cache, $form_data) {
if (FacebookPluginUtils::isInternalUser()) {
return $actions;
}
foreach ($actions as $key => $action) {
if (!isset($action['settings']) || !isset($action['settings']['type'])) {
continue;
}
$type = $action['settings']['type'];
if (!is_string($type)) {
continue;
}
// inject code when form is submitted successfully
if ($type == 'successmessage') {
$event = ServerEventFactory::safeCreateEvent(
'Lead',
array(__CLASS__, 'readFormData'),
array($form_data),
self::TRACKING_NAME,
true
);
FacebookServerSideEvent::getInstance()->track($event);
$pixel_code = PixelRenderer::render(array($event), self::TRACKING_NAME);
$code = sprintf("
<!-- Meta Pixel Event Code -->
%s
<!-- End Meta Pixel Event Code -->
", $pixel_code);
$action['settings']['success_msg'] .= $code;
$actions[$key] = $action;
}
}
return $actions;
}