Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Support for Display Features in Google Analytics #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion ganalytics.php
Expand Up @@ -34,7 +34,7 @@ public function __construct()
{ {
$this->name = 'ganalytics'; $this->name = 'ganalytics';
$this->tab = 'analytics_stats'; $this->tab = 'analytics_stats';
$this->version = '1.8.2'; $this->version = '1.8.3';
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
$this->displayName = 'Google Analytics'; $this->displayName = 'Google Analytics';
$this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8'; $this->module_key = 'fd2aaefea84ac1bb512e6f1878d990b8';
Expand Down Expand Up @@ -67,6 +67,7 @@ public function getContent()


Configuration::updateValue('GANALYTICS_ID', Tools::getValue('ganalytics_id')); Configuration::updateValue('GANALYTICS_ID', Tools::getValue('ganalytics_id'));
Configuration::updateValue('UGANALYTICS', Tools::getValue('universal_analytics')); Configuration::updateValue('UGANALYTICS', Tools::getValue('universal_analytics'));
Configuration::updateValue('DISPFEATURES', Tools::getValue('display_features'));
$output .= ' $output .= '
<div class="conf confirm"> <div class="conf confirm">
<img src="../img/admin/ok.gif" alt="" title="" /> <img src="../img/admin/ok.gif" alt="" title="" />
Expand All @@ -89,6 +90,8 @@ public function displayForm()
<p class="clear">'.$this->l('Example:').' UA-1234567-1</p> <p class="clear">'.$this->l('Example:').' UA-1234567-1</p>
<input type="checkbox" name="universal_analytics" '.(Tools::getValue('universal_analytics', Configuration::get('UGANALYTICS')) ? 'checked="checked"' : '').' /> <input type="checkbox" name="universal_analytics" '.(Tools::getValue('universal_analytics', Configuration::get('UGANALYTICS')) ? 'checked="checked"' : '').' />
<p class="clear">'.$this->l('Universal Analytics Active').'</p> <p class="clear">'.$this->l('Universal Analytics Active').'</p>
<input type="checkbox" name="display_features" '.(Tools::getValue('display_features', Configuration::get('DISPFEATURES')) ? 'checked="checked"' : '').' />
<p class="clear">'.$this->l('Implements Display Advertising features').'</p>
</div> </div>
<center><input type="submit" name="submitGAnalytics" value="'.$this->l('Update ID').'" class="button" /></center> <center><input type="submit" name="submitGAnalytics" value="'.$this->l('Update ID').'" class="button" /></center>
</fieldset> </fieldset>
Expand Down Expand Up @@ -168,6 +171,7 @@ public function hookHeader($params)


$this->context->smarty->assign('ganalytics_id', Configuration::get('GANALYTICS_ID')); $this->context->smarty->assign('ganalytics_id', Configuration::get('GANALYTICS_ID'));
$this->context->smarty->assign('universal_analytics', Configuration::get('UGANALYTICS')); $this->context->smarty->assign('universal_analytics', Configuration::get('UGANALYTICS'));
$this->context->smarty->assign('display_features', Configuration::get('DISPFEATURES'));
$this->context->smarty->assign('isOrder', false); $this->context->smarty->assign('isOrder', false);


return $this->display(__FILE__, 'views/templates/hook/header.tpl'); return $this->display(__FILE__, 'views/templates/hook/header.tpl');
Expand Down Expand Up @@ -241,6 +245,7 @@ public function hookOrderConfirmation($params)
$this->context->smarty->assign('trans', $trans); $this->context->smarty->assign('trans', $trans);
$this->context->smarty->assign('ganalytics_id', $ganalytics_id); $this->context->smarty->assign('ganalytics_id', $ganalytics_id);
$this->context->smarty->assign('universal_analytics', Configuration::get('UGANALYTICS')); $this->context->smarty->assign('universal_analytics', Configuration::get('UGANALYTICS'));
$this->context->smarty->assign('display_features', Configuration::get('DISPFEATURES'));
$this->context->smarty->assign('isOrder', true); $this->context->smarty->assign('isOrder', true);


return $this->display(__FILE__, 'views/templates/hook/header.tpl'); return $this->display(__FILE__, 'views/templates/hook/header.tpl');
Expand Down
17 changes: 15 additions & 2 deletions views/templates/hook/header.tpl
Expand Up @@ -43,6 +43,9 @@
{if $isOrder eq true} {if $isOrder eq true}
ga('require', 'ecommerce', 'ecommerce.js'); ga('require', 'ecommerce', 'ecommerce.js');
{else} {else}
{if $display_features eq true}
ga('require', 'displayfeatures');
{/if}
ga('send', 'pageview'); ga('send', 'pageview');
{/if} {/if}


Expand Down Expand Up @@ -148,10 +151,20 @@
var ga = document.createElement('script'); var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.type = 'text/javascript';
ga.async = true; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; {/literal}
{if $display_features eq true}
{literal}
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
{/literal}
{else}
{literal}
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
{/literal}
{/if}
{literal}
var s = document.getElementsByTagName('script')[0]; var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s); s.parentNode.insertBefore(ga, s);
})(); })();
{/literal} {/literal}
{/if} {/if}
</script> </script>