public static function PixelScriptBuilder::getPixelTrackCode in Official Facebook Pixel 8
Same name and namespace in other branches
- 7 src/PixelScriptBuilder.php \Drupal\official_facebook_pixel\PixelScriptBuilder::getPixelTrackCode()
Gets FB pixel track code $param is the parameter for the pixel event. If it is an array, FB_INTEGRATION_TRACKING_KEY parameter with $tracking_name value will automatically be added into the $param. If it is a string, please append the FB_INTEGRATION_TRACKING_KEY parameter with its tracking name into the JS Parameter block
6 calls to PixelScriptBuilder::getPixelTrackCode()
- PixelScriptBuilder::getPixelAddToCartCode in src/
PixelScriptBuilder.php - Gets FB pixel AddToCart code
- PixelScriptBuilder::getPixelInitiateCheckoutCode in src/
PixelScriptBuilder.php - Gets FB pixel InitiateCheckout code
- PixelScriptBuilder::getPixelLeadCode in src/
PixelScriptBuilder.php - Gets FB pixel Lead code
- PixelScriptBuilder::getPixelPageViewCode in src/
PixelScriptBuilder.php - Gets FB pixel PageView code
- PixelScriptBuilder::getPixelPurchaseCode in src/
PixelScriptBuilder.php - Gets FB pixel Purchase code
File
- src/
PixelScriptBuilder.php, line 130 - Contains \Drupal\official_facebook_pixel\PixelScriptBuilder.
Class
- PixelScriptBuilder
- Pixel object
Namespace
Drupal\official_facebook_pixelCode
public static function getPixelTrackCode($event, $param = array(), $tracking_name = '', $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)) {
if (!empty($tracking_name)) {
$param[self::FB_INTEGRATION_TRACKING_KEY] = $tracking_name;
}
$param_str = json_encode($param, JSON_PRETTY_PRINT);
}
$class = new \ReflectionClass(__CLASS__);
return sprintf($code, $class
->getConstant(strtoupper($event)) !== false ? 'track' : 'trackCustom', $event, ', ' . $param_str, '');
}