Loading facebook_pixel.libraries.yml +2 −1 Original line number Diff line number Diff line facebook_pixel: version: 1.0 version: 2.0 header: true js: js/facebook_pixel.js: {} Loading @@ -7,3 +7,4 @@ facebook_pixel: - core/jquery - core/drupal - core/drupalSettings - core/drupal.ajax js/facebook_pixel_command.js 0 → 100644 +16 −0 Original line number Diff line number Diff line /** * @file * facebook_pixel.js * * Defines the behavior of the facebook pixel module. */ (function (Drupal) { 'use strict'; Drupal.AjaxCommands.prototype.facebook_pixel_track = function (ajax, response, status) { fbq('track', response.event, response.data); } })(Drupal); src/Ajax/FacebookPixelTrackCommand.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php namespace Drupal\facebook_pixel\Ajax; use Drupal\Core\Ajax\CommandInterface; /** * Logs an event to facebook pixel. * * This command is implemented in Drupal.AjaxCommands.prototype.facebook_pixel_ * track. */ class FacebookPixelTrackCommand implements CommandInterface { /** * Event name. * * @var string */ protected $event; /** * Event data. * * @var mixed */ protected $data; /** * Constructs a \Drupal\facebook_pixel\Ajax\FacebookPixelTrackCommand object. * * @param string $event * The event name. * @param mixed $data * Assigned value. */ public function __construct($event, $data) { $this->event = $event; $this->data = $data; } /** * {@inheritdoc} */ public function render() { return [ 'command' => 'facebook_pixel_track', 'event' => $this->event, 'data' => $this->data, ]; } } Loading
facebook_pixel.libraries.yml +2 −1 Original line number Diff line number Diff line facebook_pixel: version: 1.0 version: 2.0 header: true js: js/facebook_pixel.js: {} Loading @@ -7,3 +7,4 @@ facebook_pixel: - core/jquery - core/drupal - core/drupalSettings - core/drupal.ajax
js/facebook_pixel_command.js 0 → 100644 +16 −0 Original line number Diff line number Diff line /** * @file * facebook_pixel.js * * Defines the behavior of the facebook pixel module. */ (function (Drupal) { 'use strict'; Drupal.AjaxCommands.prototype.facebook_pixel_track = function (ajax, response, status) { fbq('track', response.event, response.data); } })(Drupal);
src/Ajax/FacebookPixelTrackCommand.php 0 → 100644 +53 −0 Original line number Diff line number Diff line <?php namespace Drupal\facebook_pixel\Ajax; use Drupal\Core\Ajax\CommandInterface; /** * Logs an event to facebook pixel. * * This command is implemented in Drupal.AjaxCommands.prototype.facebook_pixel_ * track. */ class FacebookPixelTrackCommand implements CommandInterface { /** * Event name. * * @var string */ protected $event; /** * Event data. * * @var mixed */ protected $data; /** * Constructs a \Drupal\facebook_pixel\Ajax\FacebookPixelTrackCommand object. * * @param string $event * The event name. * @param mixed $data * Assigned value. */ public function __construct($event, $data) { $this->event = $event; $this->data = $data; } /** * {@inheritdoc} */ public function render() { return [ 'command' => 'facebook_pixel_track', 'event' => $this->event, 'data' => $this->data, ]; } }