• Hello,

    i would like to active this google tag only on 1 page the contact page(id=313)

    but this isnt working:

    <?php if ( is_page(313)) {
        echo '<script async src="https://www.googletagmanager.com/gtag/js?id=AW-346653908"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-346653908'); </script>';}
    endif;
    ?>

    can any one help please?

    • This topic was modified 4 years, 10 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Are you putting this in your functions.php? It’s not going to work there but you can use:

    function add_google_12bn(){
    	if(is_page(18)){
    		echo 'Your Code Here';
    	}
    }
    add_action('wp', 'add_google_12bn');

    Obviously change you page ID and your echo but the ‘wp’ will wait until, in this case, WP knows what page you are actually on.

Viewing 1 replies (of 1 total)

The topic ‘Conditional google analytics tag’ is closed to new replies.