Advertisement
qdubois

Prestashop Googel Analytics For Webgain - Header.tpl

Oct 14th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. <script type="text/javascript">
  2. var _gaq = _gaq || [];
  3. _gaq.push(['_setAccount', '{$ganalytics_id}']);
  4. // Recommanded value by Google doc and has to before the trackPageView
  5. _gaq.push(['_setSiteSpeedSampleRate', 5]);
  6.  
  7. {if isset($pageTrack)}_gaq.push(['_trackPageview', '{$pageTrack}']);{/if}
  8.  
  9. {if $isOrder eq true}       {* If it's an order we need more data for stats *}
  10.  _gaq.push(['_addTrans',
  11.     '{$trans.id}',          {* order ID - required          *}
  12.     '{$trans.store}',       {* affiliation or store name    *}
  13.     '{$trans.total}',       {* total - required             *}
  14.     '{$trans.tax}',         {* tax                          *}
  15.     '{$trans.shipping}',    {* shipping                     *}
  16.     '{$trans.city}',        {* city                         *}
  17.     '{$trans.state}',       {* state or province            *}
  18.     '{$trans.country}'      {* country                      *}
  19.  ]);
  20.  
  21.     {foreach from=$items item=item}
  22.         _gaq.push(['_addItem',
  23.         '{$item.OrderId}',      {* order ID - required      *}
  24.         '{$item.SKU}',          {* SKU/code - required      *}
  25.         '{$item.Product}',      {* product name             *}
  26.         '{$item.Category}',     {* category or variation    *}
  27.         '{$item.Price}',        {* unit price - required    *}
  28.         '{$item.Quantity}'      {* quantity - required      *}
  29.         ]);
  30.     {/foreach}
  31.     {* submits transaction to the Analytics servers *}
  32. {literal}
  33.   _gaq.push(['_trackTrans']);  
  34. {/literal}
  35. {/if}
  36. {literal}
  37. (function() {
  38.     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  39.     ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  40.     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  41. })(); {/literal}
  42. </script>
  43.  
  44.  
  45. {if $isOrder eq true and $doWebGain eq true}        {* WEBGAINS *}
  46.  
  47. <script language="javascript" type="text/javascript">
  48. if(location.protocol.toLowerCase() == "https:") wgProtocol="https";
  49. else wgProtocol="http";
  50. wgUri = wgProtocol + "{$wgUri}" + "&wgprotocol=" + wgProtocol + "&wglocation=" + location.href;
  51. document.write('<sc'+'ript language="JavaScript"  type="text/javascript" src="'+wgUri+'"></sc'+'ript>');
  52. </script>
  53.  
  54. <noscript>
  55. <img src="https://{$wgSubDomain}.webgains.com/transaction.html?wgrs=1&{$wgQueryString}&wgprotocol=https" alt="" width="1" height="1"/>
  56. </noscript>
  57.  
  58. {/if}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement