You are here

function tracking_code_init in Tracking Code 7

Implements hook_init().

File

./tracking_code.module, line 17
main module file for tracking_code module

Code

function tracking_code_init() {
  $snippets = _tracking_code_enabled_by_region();
  $node = menu_get_object();

  // Render tracking_code in <HEAD> immediately.
  // Other tracking_code will be rendered by hook_page_alter().
  foreach ($snippets['header'] as $id => $snippet) {
    drupal_add_html_head(array(
      '#type' => 'markup',
      '#markup' => token_replace($snippet->code, array(
        'node' => $node,
      )),
      '#weight' => $snippet->weight,
    ), 'tracking_code_' . $id);
  }
}