public static function PixelScriptBuilder::getPixelInitCode in Official Facebook Pixel 7
Same name and namespace in other branches
- 8 src/PixelScriptBuilder.php \Drupal\official_facebook_pixel\PixelScriptBuilder::getPixelInitCode()
Gets FB pixel init code
1 call to PixelScriptBuilder::getPixelInitCode()
File
- src/
PixelScriptBuilder.php, line 102 - Contains \Drupal\official_facebook_pixel\PixelScriptBuilder.
Class
- PixelScriptBuilder
- Pixel object
Namespace
Drupal\official_facebook_pixelCode
public static function getPixelInitCode($agent_string, $param = array(), $with_script_tag = true) {
if (empty(self::$pixelId)) {
return;
}
$code = $with_script_tag ? "<script type='text/javascript'>" . self::$pixelFbqCodeWithoutScript . "</script>" : self::$pixelFbqCodeWithoutScript;
$param_str = $param;
if (is_array($param)) {
$param_str = json_encode($param, JSON_PRETTY_PRINT);
}
$agent_param = array(
'agent' => $agent_string,
);
return sprintf($code, 'init', self::$pixelId, ', ' . $param_str, ', ' . json_encode($agent_param, JSON_PRETTY_PRINT));
}