{extends "[common]block.analytics.tpl"}

{block "google_tag_params"}
{/block}

{block "google_tag_manager_script"}
   {if $dbcfg.analytics.google_tag_manager.ID}
      <noscript><iframe src="https://www.googletagmanager.com/ns.html?id={$dbcfg.analytics.google_tag_manager.ID}" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
   {/if}
{/block}

{block "fb-pixel"}
   {if $dbcfg.analytics.fb_pixel.id}
      <!-- Facebook Pixel Code -->
      <script>
         {literal}
         !function(f,b,e,v,n,t,s)
         {if(f.fbq)return;n=f.fbq=function(){n.callMethod?{/literal}
            n.callMethod.apply(n,arguments):n.queue.push(arguments)};
            if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
            n.queue=[];{if $dbcfg.cookie_bar.enable != "Y" or !empty($smarty.cookies['cookie-bar'])}
            t=b.createElement(e);t.async=!0;
            t.src=v;s=b.getElementsByTagName(e)[0];
            s.parentNode.insertBefore(t,s){/if}}(window,document,'script',
            'https://connect.facebook.net/en_US/fbevents.js');
         fbq('init', '{$dbcfg.analytics.fb_pixel.id}', {
            em: 'insert_email_variable,'
         });
         fbq('track', 'PageView');
         {block "fb-pixel-addon"}{/block}
      </script>
      {if $dbcfg.cookie_bar.enable != "Y" or !empty($smarty.cookies['cookie-bar'])}
         <noscript><img height="1" width="1" style="display:none"
                        src="https://www.facebook.com/tr?id={$dbcfg.analytics.fb_pixel.id}&ev=PageView&noscript=1"
            /></noscript>
      {/if}
      <!-- End Facebook Pixel Code -->
   {/if}
{/block}
