AB Split Test with Child Themes

When I'm trying to use the A/B Theme Testing plugins with child themes, where only the header is changed, the plugin won't let me select the child themes. Every time I select them and save, it unchecks them. How do I fix that?

  • axialco
    • New Recruit

    We're using a custom theme and then two child themes that only have a style.css and a header.php file in both. We're testing different headers only.

    When I save, the buttons uncheck and only check the parent theme. Maybe I didn't build the child themes correctly?

  • Alexander
    • DEV MAN’s Mascot

    That is the only thing I would suspect at this point. However it could still be something unforeseen.

    In their current state do the child themes activate on their own?

    If you remove header.php temporarily will A/B accept them?

    Best regards, Alexander Rohmann

  • axialco
    • New Recruit

    I got busy and just now had a chance to try this again. Here's what I found:

    * Some of my older themes were set up incorrectly. I rebuild them with the proper CSS descriptions.

    * The child themes still didn't work, so I replicated the theme twice for three variations.

    After that, the theme switcher seemed to work, but wasn't tracking correctly in Google.

    I looked in the code and noticed that it's using the old, non-asyc _setVar() code and needs to be using _setCustomVar instead. Line 160 is this right now:
    pageTracker._setVar("<?php echo $segment; ?>");

    I replaced it with this:
    _gaq.push(['_setCustomVar', 2, 'Theme Test', "<?php echo $segment; ?>", 2]);

    Also, one other cleanup was to change $segment in line 143 from this:

    $segment = "Theme Test: ".$current_ab_theme[1];

    to this:

    $segment = $current_ab_theme[1];

    I hope that helps. You might want to rewrite and update the plugin, but do note that you'll need to update the google tracking code that's built in to be the async version.


  • Aaron
    • CTO

    I don't believe that it was ever coded to support child themes, they didn't exist when I wrote it! Can you believe this was the first plugin I wrote for WPMU DEV!?

    It could definitely use a quick update for newer tracking code and child theme support. I'll see what I can do.

  • glynndevins
    • Flash Drive

    Any additional notes on how you have this working with Async here? I tried the changes mentioned above and I'm still not seeing the custom variables in GA.

    Did you quite literally replace the old GA base code in the plugin with the Async? or should it be enough to just leave the Async code in my theme, and leave the UA field in the plugin blank?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.