Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1211968
    Nic Design
    Participant

    I have a client who wants to do some AB testing and signed up with Optimizely. They have a script to add the pages that will be tested but when I add it to the page via cornerstone the script does not get added properly. It looks like cornerstone automatically adds it’s own opening and closing script tag which is causing the issue as the script is basically just an opening tag with a src (<script src=”https://cdn.optimizely.com/js/7495431271.js”></script&gt;). I found this other article (https://community.theme.co/forums/topic/optimizely-is-not-loading-the-site) but that adds the script to every page and if I add it through the customizer it also adds it to every page. Is there a way to add the script to just the pages I want?

    #1212130
    Jade
    Moderator

    Hi there,

    Kindly refer on this related thread for suggestion

    https://community.theme.co/forums/topic/adding-code-into-header-on-a-specific-page/#post-117550

    Hope this helps.

    #1216865
    Nic Design
    Participant

    Thank you. That was helpful but can you tell me how to add to multiple pages? Do I just copy and repeat the code with a different page ID or do I use the same function with an “or” condition for the other pages?

    #1217064
    Christopher
    Moderator

    Hi there,

    if you want to add it to all pages, update your code to :

    add_action('wp_head','additaional_track_script');
    function additaional_track_script() {
      if( is_page( ) ) {?>
    <!--replace this line with your tracking this -->
    <?php
     }
    }

    If you want to add script to specific pages, update it to :

    add_action('wp_head','additaional_track_script');
    function additaional_track_script() {
      if( is_page(185) || is_page(10) || is_page(34)) {?>
    <!--replace this line with your tracking this -->
    <?php
     }
    }

    Hope it helps.

  • <script> jQuery(function($){ $("#no-reply-1211968 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>