public static function injectLeadEvent()

in integration/FacebookWordpressContactForm7.php [86:110]


  public static function injectLeadEvent($response, $result) {
    if (FacebookPluginUtils::isInternalUser()) {
      return $response;
    }

    $events = FacebookServerSideEvent::getInstance()->getTrackedEvents();
    if( count($events) == 0 ){
      return $response;
    }
    $event_id = $events[0]->getEventId();
    $fbq_calls = PixelRenderer::render($events, self::TRACKING_NAME, false);
    $code = sprintf("
if( typeof window.pixelLastGeneratedLeadEvent === 'undefined'
  || window.pixelLastGeneratedLeadEvent != '%s' ){
  window.pixelLastGeneratedLeadEvent = '%s';
  %s
}
      ",
      $event_id ,
      $event_id ,
      $fbq_calls);

    $response['fb_pxl_code'] = $code;
    return $response;
  }