• Resolved James

    (@jamessui-1)


    Hi,

    Is it possible to disable/remove Analytics tracking code on certain pages in the CMS?

    Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Support Adam Dunnage

    (@adamdunnage)

    Hi @jamessui-1 thanks for getting in touch. There is no current built in way to achieve this but it can be done using a filter. If you were looking to disable Analytics for all pages on your site then you could use the following:

    add_filter( ‘googlesitekit_analytics-4_tag_blocked’, ‘__return_true’ );

    To disable Analytics on specific pages of your website then you can use the following:

    add_filter( ‘googlesitekit_analytics-4_tag_blocked’, ‘restrict_analytics_snippet’ );
    function restrict_analytics_snippet( $original ){
    ?// don’t place Analytics on page with ID of *
    ??if (is_page( * ) )
    return true;
    }

    You will just need to replace the * with the page ID(s) you wish to disable Analytics for and the Site Kit Analytics code will not be placed on that page. This filter should ideally be added to a custom functions plugin or a child theme, rather than the main themes functions.php file (which would get overwritten on theme updates).

    This filter can also be adapted for other posts, categories etc. but further customisation does fall out of the range of the support we can provide here. Hope this helps to answer your question.

Viewing 1 replies (of 1 total)
  • The topic ‘Turn off Analytics on certain pages?’ is closed to new replies.