class AmpTrackingPixelAnalyticsService in Analytics 7
Hierarchy
- class \AnalyticsService implements AnalyticsServiceInterface
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'],
),
);
}
}
}