Skip to content

Instantly share code, notes, and snippets.

@carcam
Last active December 1, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carcam/82eeea7b4b938126d8d9e205b8a51c27 to your computer and use it in GitHub Desktop.
Save carcam/82eeea7b4b938126d8d9e205b8a51c27 to your computer and use it in GitHub Desktop.
Override del módulo oficial de Analytics de PrestaShop 1.7 para usarlo sin cookies (Cookieless Analytics)
{**
* 2014-2020 Hepta Technologies SL
*
* INSTRUCCIONES:
*
* ESTE OVERRIDE SÓLO FUNCIONA PARA LA VERSIÓN 1.7 DE PRESTASHOP Y USANDO EL MÓDULO OFICIAL DE GOOGLE ANALYTICS
*
* Una vez configurado el módulo, sube este fichero a:
*
* /themes/[CARPETA DE TU TEMA]/modules/ps_googleanalytics/views/templates/hook/ps_googleanalytics.tpl
*
* Donde tienes que sustituir [CARPETA DE TU TEMA] por el nombre que tenga la carpeta del tema PrestaShop que estés utilizando.
*
* Es más que probable que tengas que crear todas las carpetas después de "modules". Si no tienes que hacerlo, consulta los cambiosç
* tiene tu sitio en este fichero y comprueba que todo seguirá funcionando como esperas.
*
* @author Carlos Cámara <carlos@hepta.es>
* @copyright 2014-2020 Hepta Technologies SL
*}
{literal}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fingerprintjs/0.5.3/fingerprint.min.js"></script>
<script type="text/javascript">
(window.gaDevIds=window.gaDevIds||[]).push('d6YPbH');
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
{/literal}
{if $gaCrossdomainEnabled}
ga('create', '{$gaAccountId|escape:'htmlall':'UTF-8'}', 'auto', {literal}{'allowLinker': true}{/literal});
ga('require', 'linker');
ga('linker:autoLink', [
{foreach from=$shops item=shop}
{if $shop.id_shop != $currentShopId}
{if $useSecureMode}'{$shop.domain_ssl|escape:'htmlall':'UTF-8'}'{else}'{$shop.domain|escape:'htmlall':'UTF-8'}'{/if},
{/if}
{/foreach}
]);
{else}
ga('create', '{$gaAccountId|escape:'htmlall':'UTF-8'}', {literal}{'storage': 'none', 'clientId': new Fingerprint().get()}{/literal});
{/if}
{if $userId && !$backOffice}
ga('set', 'userId', '{$userId|escape:'htmlall':'UTF-8'}');
{/if}
{if $gaAnonymizeEnabled}
ga('set', 'anonymizeIp', true);
{/if}
{if $backOffice}
ga('set', 'nonInteraction', true);
{else}
ga('send', 'pageview');
{/if}
{literal}
ga('require', 'ec');
</script>
{/literal}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment