Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1049372

    Hello,

    I have a simple enfold website without woocommerce.

    I do Google Ads and would like to add the conversion tracking code. The conversion is a specific page load.

    What is the best way to add the global site tag and the event snippet?

    Thank you in advance!

    Hazlitt

    • This topic was modified 5 years, 11 months ago by Hazlitt. Reason: typing error
    #1049508

    Hey Hazlitt,

    What code do you need to add and where? Please try to be as specific as possible.

    Best regards,
    Rikard

    #1049564

    Hey Rikard,

    The global site tag adds visitors to your basic remarketing lists and sets new cookies on your domain, which will store information about the ad click that brought a user to your website. You must install this tag on every page of your website.

    Copy the tag below and paste it in between the <head></head> tags of every page of your website. You only need to install the global site tag once per account, even if you’re tracking multiple actions.

    <!– Global site tag (gtag.js) – Google Ads: 123456789 –>
    <script async src=”https://www.googletagmanager.com/gtag/js?id=AW-123456789″></script&gt;
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(‘js’, new Date());

    gtag(‘config’, ‘AW-123456789’);
    </script>

    The event snippet works with the global site tag to track actions that should be counted as conversions…
    Add the snippet to the page that a customer reaches after completing a conversion:
    Copy the snippet below and paste it in between the <head></head> tags of the page that you’d like to track, right after the global site tag.

    <!– Event snippet for xyz conversion page –>
    <script>
    gtag(‘event’, ‘conversion’, {‘send_to’: ‘AW-123456789/xxxxxx_NUD’});
    </script>

    Best regards,
    Hazlitt

    • This reply was modified 5 years, 11 months ago by Hazlitt.
    #1049800

    Hi,

    Thanks for that, please try this in your functions.php file:

    function hazlitt_add_goole_scripts(){
      ?>
      <script async src=”https://www.googletagmanager.com/gtag/js?id=AW-123456789″></script>
      <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag(‘js’, new Date());
    
      gtag(‘config’, ‘AW-123456789’);
      </script>
      <script>
      gtag(‘event’, ‘conversion’, {‘send_to’: ‘AW-123456789/xxxxxx_NUD’});
      </script>  
      <?php
    }
    add_action('wp_head', 'hazlitt_add_goole_scripts');

    Best regards,
    Rikard

    #1054106

    Hi,
    Is this: add_action(‘wp_head’, ‘hazlitt_add_goole_scripts’);
    is the page where the header will contain this script?
    If that so how should I write the name of the page in my case?

    #1054266

    Hi vntr,

    Yes, this will be shown in all pages.

    You need to add the check for which page id it is

    If you need further assistance please let us know.
    Best regards,
    Victoria

    #1054504
    This reply has been marked as private.
    #1055513

    Hi vntr,

    Here is the code you can put in your funtions.php

    
    function hazlitt_add_goole_scripts(){
    	if (is_page(9012)) {
      ?>
    	  <script async src=”https://www.googletagmanager.com/gtag/js?id=AW-123456789″></script>
    	  <script>
    	  window.dataLayer = window.dataLayer || [];
    	  function gtag(){dataLayer.push(arguments);}
    	  gtag(‘js’, new Date());
    
    	  gtag(‘config’, ‘AW-123456789’);
    	  </script>
    	  <script>
    	  gtag(‘event’, ‘conversion’, {‘send_to’: ‘AW-123456789/xxxxxx_NUD’});
    	  </script>  
    	  <?php
    	}
    }
    add_action('wp_head', 'hazlitt_add_goole_scripts');
    

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.