• Resolved Wendihihihi

    (@wendihihihi)


    Hi,

    I’m use the gtag tracking script. Your plugin still uses the old tracking system, analytics.js. How can I manually add the tracking script I am using?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello @wendihihihi,

    You can use wpmm_head hook to add gtag.js script.

    Example:

    
    // this snippet should be placed inside functions.php of your theme or child-theme
    add_action('wpmm_head', 'wpmm_head_gtag_script');
    
    function wpmm_head_gtag_script() {
    	echo "<script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXX\"></script>
            <script>
                window.dataLayer = window.dataLayer || [];
                function gtag() {
                    dataLayer.push(arguments);
                }
                gtag('js', new Date());
    
                gtag('config', 'UA-XXXXXXX');
            </script>";
    }
    

    You have to replace UA-XXXXXXX with your real Google Analytics ID.

    George

    • This reply was modified 6 years, 7 months ago by George J.
    • This reply was modified 6 years, 7 months ago by George J.
    • This reply was modified 6 years, 7 months ago by George J.
    Thread Starter Wendihihihi

    (@wendihihihi)

    Thanks George, very helpful.

    • This reply was modified 6 years, 7 months ago by Wendihihihi.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Analytics gtag’ is closed to new replies.