$this->config->statsMatomo = false;
}
- if ($this->fluidbookSettings->tagcommander_id) {
- $id = $this->fluidbookSettings->tagcommander_id;
- if (!$this->fluidbookSettings->tagcommander_prod) {
- $id .= '/uat';
- }
-
- $default = ['page_name' => ''];
- $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->fluidbookSettings->tagcommander_default_vars));
- $this->config->set('tagcommander_default_vars.env_work', $this->fluidbookSettings->tagcommander_prod ? 'prod' : 'pre-prod');
+ $this->_tagCommander();
- $scriptNames = explode(',', $this->config->tagcommander_scriptname);
- $this->fluidbookSettings->googleAnalyticsCustom .= '<script>window.tc_vars=' . json_encode($this->config->tagcommander_default_vars) . ';</script><script src="//cdn.tagcommander.com/' . $id . '/' . $scriptNames[0] . '"></script>';
- for ($i = 1; $i < count($scriptNames); $i++) {
- $this->fluidbookSettings->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/' . $scriptNames[$i] . '"></script>';
- }
-
- if ($this->fluidbookSettings->tagcommander_plan) {
- $this->config->tagcommander_plan = $this->_parsePlan($this->fluidbookSettings->tagcommander_plan);
- }
- }
if (isset($this->fluidbookSettings->googleTagManager) && $this->fluidbookSettings->googleTagManager) {
$this->fluidbookSettings->googleAnalyticsCustom .= "<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->';
}
+
if ($this->fluidbookSettings->xiti) {
$this->fluidbookSettings->googleAnalyticsCustom .= $this->fluidbookSettings->xiti;
if ($this->fluidbookSettings->piano_plan) {
}
}
+ protected function _tagCommander()
+ {
+ if ($this->fluidbookSettings->tagcommander_plan_type === 'file') {
+ if ($this->fluidbookSettings->tagcommander_id) {
+ $id = $this->fluidbookSettings->tagcommander_id;
+ if (!$this->fluidbookSettings->tagcommander_prod) {
+ $id .= '/uat';
+ }
+
+ $default = ['page_name' => ''];
+ $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->fluidbookSettings->tagcommander_default_vars));
+ $this->config->set('tagcommander_default_vars.env_work', $this->fluidbookSettings->tagcommander_prod ? 'prod' : 'pre-prod');
+
+ $scriptNames = explode(',', $this->config->tagcommander_scriptname);
+
+
+ if ($this->fluidbookSettings->tagcommander_plan) {
+ $this->config->tagcommander_plan = $this->_parsePlan($this->fluidbookSettings->tagcommander_plan);
+ }
+ }
+ } else if ($this->fluidbookSettings->tagcommander_plan_type === 'esm') {
+ $default = [
+ 'env_ati_id' => 576078,
+ 'page_name' => 'magazine',
+ 'env_work' => $this->fluidbookSettings->tagcommander_prod ? 'prod' : 'pre-prod',
+ 'page_level_name' => 'fluidbook',
+ 'magazine_device' => $this->isMobileFirst() ? 'mobile' : 'desktop',
+ ];
+ $this->config->tagcommander_default_vars = array_merge($default, $this->parseVariables($this->fluidbookSettings->tagcommander_default_vars));
+ $id = 5040;
+ if (!$this->fluidbookSettings->tagcommander_prod) {
+ $id .= '/uat';
+ }
+ $scriptNames = ['tc_Multisite_Medias.js', 'tc_Multisite_Analytics.js'];
+ $this->addJsLib('esm', ['js/fluidbook/stats/fluidbook.stats.esm.js']);
+ }
+
+ if (isset($id)) {
+ $this->fluidbookSettings->googleAnalyticsCustom .= '<script>window.tc_vars=' . json_encode($this->config->tagcommander_default_vars) . ';</script><script src="//cdn.tagcommander.com/' . $id . '/' . $scriptNames[0] . '"></script>';
+ for ($i = 1; $i < count($scriptNames); $i++) {
+ $this->fluidbookSettings->statsCustom .= '<script src="//cdn.tagcommander.com/' . $id . '/' . $scriptNames[$i] . '"></script>';
+ }
+ }
+
+ }
+
protected function _parsePlan($filename)
{
$planPath = $this->_wdirOrAbsolute($filename);
);
$this->addSettingField('tagcommander_id', LongText::class, 'Tag commander ID', [
'v2' => '{"type":"text","default":"","editable":true,"label":"Tag commander ID","grade":3}',
+ 'when' => ['tagcommander_plan_type' => 'file'],
]);
$this->addSettingField('tagcommander_scriptname', LongText::class, 'Nom du script Tagcommander', [
'v2' => '{"type":"text","default":"tc_Multisite_Head.js,tc_Multisite_Analytics.js,tc_Multisite_Medias.js","editable":true,"label":"Nom du script Tagcommander","grade":3}',