You are here

class AmpTrackingPixelAnalyticsService in Analytics 7

Hierarchy

Expanded class hierarchy of AmpTrackingPixelAnalyticsService

1 string reference to 'AmpTrackingPixelAnalyticsService'
analytics_amp_analytics_service_info in analytics_amp/analytics_amp.module
Implements hook_analytics_service_info().

File

analytics_amp/src/AmpTrackingPixelAnalyticsService.php, line 3

View source
class AmpTrackingPixelAnalyticsService extends AnalyticsService {

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return array(
      'url' => '',
    );
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm($form, &$form_state) {
    $options['url'] = array(
      '#title' => t('URL'),
      '#type' => 'urlfield',
      '#default_value' => $this
        ->getConfiguration()['url'],
      '#description' => t('See the <a href="@url">substitutions guide</a> to see what variables can be included in the URL.', array(
        '@url' => 'https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md',
      )),
      '#required' => TRUE,
      '#placeholder' => 'https://foo.com/pixel?RANDOM',
    );
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public function getOutput(array $context) {
    if (amp_is_amp_request()) {
      return array(
        '#theme' => 'html_tag',
        '#tag' => 'amp-pixel',
        '#attributes' => array(
          'id' => drupal_html_id('analytics_' . $this
            ->getMachineName()),
          'src' => $this
            ->getConfiguration()['url'],
        ),
      );
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AmpTrackingPixelAnalyticsService::buildConfigurationForm public function Form constructor. Overrides AnalyticsService::buildConfigurationForm
AmpTrackingPixelAnalyticsService::defaultConfiguration public function Overrides AnalyticsService::defaultConfiguration
AmpTrackingPixelAnalyticsService::getOutput public function Returns the output of the analytics service. Overrides AnalyticsServiceInterface::getOutput
AnalyticsService::$description private property
AnalyticsService::$hasMultiple protected property
AnalyticsService::$label private property
AnalyticsService::$machine_name private property
AnalyticsService::$options private property
AnalyticsService::$service private property
AnalyticsService::canTrack public function Determines if the current service can track the current request. Overrides AnalyticsServiceInterface::canTrack
AnalyticsService::getAmpOutput public function Build an <amp-analytics> tag for output on an amp-enabled page request.
AnalyticsService::getCacheableUrls public function Overrides AnalyticsServiceInterface::getCacheableUrls 2
AnalyticsService::getConfiguration public function Overrides AnalyticsServiceInterface::getConfiguration
AnalyticsService::getDescription public function Returns the description of the plugin instance. Overrides AnalyticsServiceInterface::getDescription
AnalyticsService::getLabel public function Returns the label of the plugin instance. Overrides AnalyticsServiceInterface::getLabel
AnalyticsService::getMachineName public function Returns the machine name of the analytics plugin instance. Overrides AnalyticsServiceInterface::getMachineName
AnalyticsService::getService public function Returns the type of the plugin instance. Overrides AnalyticsServiceInterface::getService
AnalyticsService::hasMultipleInstances public function
AnalyticsService::__construct public function