You are here

public static function OfficialFacebookPixelInjection::injectScriptCode in Official Facebook Pixel 8

Same name and namespace in other branches
  1. 7 src/OfficialFacebookPixelInjection.php \Drupal\official_facebook_pixel\OfficialFacebookPixelInjection::injectScriptCode()
1 call to OfficialFacebookPixelInjection::injectScriptCode()
OfficialFacebookPixelInjection::injectPixelCode in src/OfficialFacebookPixelInjection.php

File

src/OfficialFacebookPixelInjection.php, line 45
Contains \Drupal\official_facebook_pixel \OfficialFacebookPixelInjection.

Class

OfficialFacebookPixelInjection
Class OfficialFacebookPixelInjection.

Namespace

Drupal\official_facebook_pixel

Code

public static function injectScriptCode(array &$page, $options) {

  // Inject inline script code to head
  $pixel_script_code = PixelScriptBuilder::getPixelBaseCode();
  $pixel_script_code .= PixelScriptBuilder::getPixelInitCode($options
    ->getAgentString(), $options
    ->getUserInfo());
  $pixel_script_code .= PixelScriptBuilder::getPixelPageViewCode();
  $page['#attached']['html_head'][] = [
    [
      '#tag' => 'script',
      '#value' => $pixel_script_code,
    ],
    'facebook_pixel_script_code',
  ];
}