function hook_google_tag_snippets_alter in GoogleTagManager 7
Same name and namespace in other branches
- 8 google_tag.api.php \hook_google_tag_snippets_alter()
- 7.2 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.
1 invocation of hook_google_tag_snippets_alter()
- google_tag_snippets in includes/
snippet.inc - Returns JavaScript snippets.
File
- ./
google_tag.api.php, line 55 - Documents hooks provided by this module.
Code
function hook_google_tag_snippets_alter(array &$snippets) {
// Do something to the script snippet.
$snippets['script'] = str_replace('insertBefore', 'insertAfter', $snippets['script']);
}