Skip to content

GoogleTagManager

Google Tag Manager analytics service plugin.


Methods

defaultConfiguration

{@inheritdoc}

public defaultConfiguration(): array

buildConfigurationForm

{@inheritdoc}

public buildConfigurationForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state): array

Parameters:

Parameter Type Description
$form array
$form_state \Drupal\Core\Form\FormStateInterface

getOutput

Returns the output of the analytics service.

public getOutput(): array

Return Value:

A structured, renderable array.


getCspSources

Gets the Content Security Policy sources the service's output needs.

public getCspSources(): array<string,string[]>

The container's own tags may need more sources.

Return Value:

URLs keyed by directive, such as ['script-src' => ['https://gc.zgo.at']].

See Also:

  • https://developers.google.com/tag-platform/security/guides/csp

defaultData

{@inheritdoc}

public defaultData(): mixed

Inherited methods

setServiceId

Sets the current service config entity ID that is using this plugin.

public setServiceId(mixed $service_id): mixed

Parameters:

Parameter Type Description
$service_id mixed
The service config entity ID.

getServiceId

Gets the current service config entity ID that is using this plugin.

public getServiceId(): string

Return Value:

The service config entity ID.


__construct

{@inheritdoc}

public __construct(array $configuration, mixed $plugin_id, mixed $plugin_definition): mixed

Parameters:

Parameter Type Description
$configuration array
$plugin_id mixed
$plugin_definition mixed

create

{@inheritdoc}

public static create(\Symfony\Component\DependencyInjection\ContainerInterface $container, array $configuration, mixed $plugin_id, mixed $plugin_definition): static
  • This method is static. Parameters:
Parameter Type Description
$container \Symfony\Component\DependencyInjection\ContainerInterface
$configuration array
$plugin_id mixed
$plugin_definition mixed

getLabel

Returns the label of the analytics service.

public getLabel(): string

Return Value:

The label of this analytics service.


access

{@inheritdoc}

public access(mixed $operation, ?\Drupal\Core\Session\AccountInterface $account = null, mixed $return_as_object = false): mixed

Parameters:

Parameter Type Description
$operation mixed
$account ?\Drupal\Core\Session\AccountInterface
$return_as_object mixed

hasMultipleInstances

Checks whether more than one analytics service uses this plugin.

public hasMultipleInstances(): bool

Return Value:

TRUE if two or more analytics services use this plugin.


getOutput

Returns the output of the analytics service.

public getOutput(): array

Return Value:

A structured, renderable array.


getCspSources

Gets the Content Security Policy sources the service's output needs.

public getCspSources(): array<string,string[]>

Return Value:

URLs keyed by directive, such as ['script-src' => ['https://gc.zgo.at']].


getCacheableUrls

Gets the URLs of the service's external files to cache locally.

public getCacheableUrls(): array

Return Value:

A list of URLs.


getCacheContexts

{@inheritdoc}

public getCacheContexts(): array

The output's cacheability. Plugins that vary their output by something other than their configuration add it here.


getCacheTags

{@inheritdoc}

public getCacheTags(): array

getCacheMaxAge

{@inheritdoc}

public getCacheMaxAge(): int

setConfiguration

{@inheritdoc}

public setConfiguration(array $configuration): mixed

Parameters:

Parameter Type Description
$configuration array

getConfiguration

{@inheritdoc}

public getConfiguration(): array

defaultConfiguration

{@inheritdoc}

public defaultConfiguration(): array

buildConfigurationForm

{@inheritdoc}

public buildConfigurationForm(array $form, \Drupal\Core\Form\FormStateInterface $form_state): array

Parameters:

Parameter Type Description
$form array
$form_state \Drupal\Core\Form\FormStateInterface

validateConfigurationForm

{@inheritdoc}

public validateConfigurationForm(array& $form, \Drupal\Core\Form\FormStateInterface $form_state): mixed

Parameters:

Parameter Type Description
$form array
$form_state \Drupal\Core\Form\FormStateInterface

submitConfigurationForm

{@inheritdoc}

public submitConfigurationForm(array& $form, \Drupal\Core\Form\FormStateInterface $form_state): mixed

Parameters:

Parameter Type Description
$form array
$form_state \Drupal\Core\Form\FormStateInterface

calculateDependencies

{@inheritdoc}

public calculateDependencies(): array

defaultData

Gets the service's default data, before it's altered.

public defaultData(): array
  • This method is abstract. Return Value:

The default data.


getData

Gets the service's data, altered by other modules.

public getData(\Drupal\Core\Cache\RefinableCacheableDependencyInterface|null $cacheability = null): array

Invokes hook_analytics_SERVICE_ID_data_alter(), and also hook_analytics_PLUGIN_ID_data_alter() when the plugin ID differs.

Parameters:

Parameter Type Description
$cacheability \Drupal\Core\Cache\RefinableCacheableDependencyInterface|null
(optional) Collects the cacheability the alter hooks add, for the caller
to apply to the output.

Return Value:

The altered data.


moduleHandler

Wraps the module handler.

protected moduleHandler(): \Drupal\Core\Extension\ModuleHandlerInterface
  • This method is abstract. Return Value:

The module handler.