You are here

function hook_google_tag_snippets_alter in GoogleTagManager 7.2

Same name and namespace in other branches
  1. 8 google_tag.api.php \hook_google_tag_snippets_alter()
  2. 7 google_tag.api.php \hook_google_tag_snippets_alter()

Alter the snippets to be inserted on a page response.

This hook allows other modules to alter the snippets to be inserted based on custom settings not defined by this module.

Parameters

array $snippets: Associative array of snippets keyed by type: script, noscript and data_layer.

GTMContainer $container: The associated container object.

1 invocation of hook_google_tag_snippets_alter()
GTMContainer::snippets in includes/entity/container.inc
Returns array of JavaScript snippets.

File

./google_tag.api.php, line 59
Hooks provided by this module.

Code

function hook_google_tag_snippets_alter(array &$snippets, $container) {

  // Do something to the script snippet.
  $snippets['script'] = str_replace('insertBefore', 'insertAfter', $snippets['script']);
}