Matt Dawson
Matt Dawson

Reputation: 1

Add GA Experiments to .php for specific homepages for an a/b test

I have been really struggling with something, wondered if anyone could help.

I am trying to run a Google Experiment to A/B test my homepage to a variation homepage that i've already created in Wordpress.

I need to add the Google analytics code to the of the two homepage's, i think i need a php code to target the two homepage's.

I previously used (many) Wordpress plugin's and each plugin wouldn't let me specify where the code hit, it just ran the code across the whole site, so I was getting the variation homepage on every link i clicked through on my site.

This is my header.php and i think i need a php code to specify the two homepage's to attack with the Google experiment code?

<header class="banner container" role="banner">
<div class="row">
    <div class="col-lg-12">
      <a class="brand" href="<?php echo esc_url(home_url()); ?>/"><?php bloginfo('name'); ?></a>
      <nav class="nav-main" role="navigation">
        <?php
          if (has_nav_menu('primary_navigation')) :
            wp_nav_menu(array('theme_location' => 'primary_navigation', 'menu_class' => 'nav nav-pills'));
          endif;
        ?>
      </nav>
    </div>
  </div>

</header>

Thanks in advance, any help would be much appreciated.

Matt (SEO and CRO intern)

Upvotes: 0

Views: 68

Answers (0)

Related Questions