public function GTMContainer::insertSnippet in GoogleTagManager 7.2
Determines whether to insert the snippet on the response.
Return value
bool TRUE if the conditions are met; FALSE otherwise.
File
- includes/
entity/ container.inc, line 353
Class
- GTMContainer
- Defines the container configuration entity.
Code
public function insertSnippet() {
static $satisfied = array();
if (!isset($satisfied[$this->name])) {
$id = $this
->get('container_id');
if (empty($id)) {
// No container ID.
return $satisfied[$this->name] = FALSE;
}
$this
->displayMessage('google_tag container ' . $this->name);
$satisfied[$this->name] = TRUE;
$types = google_tag_condition_filter();
foreach ($types as $type => $value) {
if (is_array($value) && isset($value['file'])) {
$result = TRUE;
$function = "_google_tag_condition_evaluate_{$type}";
if (function_exists($function)) {
$result = $function($this);
}
}
else {
$result = $this
->genericCheck($type);
}
if (!$result) {
// Omit snippet if any condition is not met.
$satisfied[$this->name] = FALSE;
break;
}
}
// Allow other modules to alter the insertion criteria.
drupal_alter('google_tag_insert', $satisfied[$this->name], $this);
$this
->displayMessage('after alter @satisfied', array(
'@satisfied' => $satisfied[$this->name],
));
}
return $satisfied[$this->name];
}