Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1472676

    Can we add a Google tag code and a Google Analytics code under the enfold theme -> Google Analytics box?

    #1472678

    Hey amyncuih,

    Thank you for the inquiry.

    Yes, you can add both embed codes in the Google Analytics field or use hooks such as wp_head if you want to separate the Google Tag embed code.

    Example:

    function ava_add_google_tag_code() {
        ?>
        <!-- Google Tag Embed Code -->
        <script async src="https://www.googletagmanager.com/gtag/js?id=YOUR_TAG_ID"></script>
        <script>
            window.dataLayer = window.dataLayer || [];
            function gtag(){dataLayer.push(arguments);}
            gtag('js', new Date());
            gtag('config', 'YOUR_TAG_ID');
        </script>
        <?php
    }
    add_action('wp_head', 'ava_add_google_tag_code');
    
    

    More info: https://developer.wordpress.org/reference/hooks/wp_head/

    Best regards,
    Ismael

    #1473948

    How do I add both codes? with a comma?

    #1473986

    Hi,

    Thank you for the update.

    You have to insert the complete embed code if you want to include both scripts in the same field, or use the template hook as suggested above. Let us know if you need more assistance.

    Best regards,
    Ismael

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