Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1401536

    Hi,

    I have been asked to add this GA4 Code into every page after the Head tag.

    I have not come across this before, Can it not be added in the functions.php only once?

    Thanks

    #1401621

    Hey woogie07,
    Please try adding it to the Enfold Theme Options ▸ Google Services ▸ Google Analytics Tracking Code field.
    If you really want to add it to your child theme functions.php add it into this function:

    function custom_head_script() { ?>
      <script>
    //your code here
      </script>
      <?php
    }
    add_action('wp_head', 'custom_head_script', 10 );

    Best regards,
    Mike

    #1401805

    hi,

    I also need to add some script in the body tag

    Is this located on the header.php or can it be added in Google Services?

    #1401826

    Hi,

    You can use this function in functions.php for that:

    function woogie07_after_body_tag() { 
    ?>
    Your script goes here
    <?php
    }
    add_action('ava_after_body_opening_tag', 'woogie07_after_body_tag');

    Best regards,
    Rikard

    #1401836

    Thanks

    Where does the code go within the function.php eg which line?
    start/finish etc.

    Is the private content correct

    #1401874

    Hi,

    Please add it to the bottom of functions.php in your child theme. The function you posted in private looks correct.

    Best regards,
    Rikard

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