Jump to content

Prestashop 1.7 GTM Smarty


espacious

Recommended Posts

Pozdravljeni,

nikakor mi ne uspe vstaviti GTM (google Tag Manager) kode v order-confirmation.tpl, v header in body sem vstavil potrebno kodo za povezavo GTM in to deluje.

Prilagam screenshoot-e.

1316199138_UnnamedQQScreenshot20181211094317.png.cc25e361202c24b644fc8a249f7a88fa.png1622748890_QQPhoto20181211094339.jpg.2748896e0a9f267baebcf9055b91e53e.jpg

Zatakne se mi pri delu kode "dataLayer" katerega naj bi vstavil v order-confirmation.tpl, nikakor mi ne usepe zaobjeti kode v {literal} koda... {/literal}

Pripenjam 3 primere katere sem preizkusil, vsaka pomoč dobrodošla. Hvala

<!-- Google Tag Manager  dataLayer -->
{if isset($page_name) && $page_name|escape:'html':'UTF-8' == "order-confirmation"}
        <script type="text/javascript">
        window.dataLayer = window.dataLayer || []
        dataLayer.push({ldelim}
           'transactionId': '{$id_order}',
           'transactionTotal': {$total_paid_tax_incl},
           'transactionProducts': [
           {foreach from=$products item=product}
               {ldelim}                            
                   // List of productFieldObjects.
                   'sku': '{$product.id}',
                   'name': '{$product.name}',     // Name or ID is required.
                   //'category': '{$product.X}',
                   'price': {$product.price},
                   'quantity': 1                  // Optional fields may be omitted or set to empty string.
               {rdelim}
               {if !$smarty.foreach.product.last},{/if}
           {/foreach}
        ]
        {rdelim});
        </script>
{/if}
<!-- End Google Tag Manager  dataLayer -->
<!-- Google Tag Manager  dataLayer -->
{literal}
<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'transactionId': {$id_order},
  'transactionTotal': {$transaction_total},
  'transactionTax': {$tax},
  'transactionShipping': {$shipping_total},
  'transactionProducts': {foreach from=$products item=product name=products}
{
  'sku': {$product.id_product},
  'name': {$product.name},
  'price': {$product.price_wt},
  'quantity': {$product.quantity}
}
  {if $smarty.foreach.products.iteration != $products|@count},
    {/if}
  {/foreach},
'event': 'transactionComplete'
})
</script>
{/literal}
<!-- End Google Tag Manager  dataLayer -->
<!-- Google Tag Manager  dataLayer -->
{literal}
<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
dataLayer.push({
  'ecommerce': {
    'purchase': {
      'actionField': {
        'id': '{$id_order}',
        'affiliation': '',
        'revenue': '{$transaction_total}',
        'tax': '{$tax}',
        'shipping': '{$shipping_total}',
        'coupon': ''
      },
      'products': {foreach from=$products item=product name=products}
        {                           
        'name': '{$product.name}',    
        'id': '{$product.id_product}',
        'price': '{$product.price_wt}',
        'brand': '{$products.manufacturer_name}',
        'category': '{$product.category}',
        'variant': '',
        'quantity': '{$product.quantity}',
        'coupon': ''                            
           }
        {if $smarty.foreach.products.iteration != $products|@count},
           {/if}
        {/foreach}
    }
  }
});
</script>
{/literal}
<!-- End Google Tag Manager  dataLayer -->

Prilagam še povezave s katerih sem črpal:

https://www.initcoms.com/blog/como-utilizar-google-tag-manager-en-prestashop/

https://canonicalized.com/enhanced-ecommerce-tag-manager/?section=start-off-right

Link to comment
Share on other sites

jaz uporabljam tega prilepljenega in dela OK, tudi preklicane naročila zabeleži. Problem je edino odkar je gdpr v veljavi, ker imamo seveda tehnično tudi urejen GDPR in če se ne strinja z namestitvijo piškotkov, potem tega naročila/preklica ne zabeleži.

image.png.8fdc4e115a9c444cb5afd09b754beb6d.png

Link to comment
Share on other sites

Aha ok bom malo pogledal oz nabavil kar tega ki priporočste, ampak še vedno bi rad vedel kako ročno vstaviti kodo.

Glede GDPR in piškotkov pa je logično ja, lahko pa bi se tiste piškotke smatralo kot obvezne, tako da jih stranka pač nemore izklopit, ter se to zapiše v TOS.

Link to comment
Share on other sites

ja, to že vem, samo potem moraš vse ločevat, in FB pixel in druge stvari, tako pa imaš na enem mestu vse kode in če se strinja potem se beleži, če se ne strinja se ne beleži. sam sem se nehal obremenjevati z to statistiko, ker sem potem cele dneve gledal samo v to, namesto, da bi se ukvarjal z pomembnejšimi stvarmi :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...