• Have a add_action in my functions.php to display an adsense ad in my posts using a Hook:
    genesis_after_header – Genesis Framework Hooks )
    add_action(‘genesis_after_header’, ‘topadd0’);

    However I want to A/B test this Hook&ad vs another Hook&Ad (be aware this is another hook and another ad variation):
    genesis_before_loop – Genesis Framework Hooks )
    add_action(‘genesis_before_loop’, ‘topadd1’);

    How can I randomize the add_action to display either:
    add_action(‘genesis_after_header’, ‘topadd0’);
    or
    add_action(‘genesis_before_loop’, ‘topadd1’);

Viewing 2 replies - 1 through 2 (of 2 total)
  • Something like this maybe?

    if (mt_rand (0, 1) == 0) {
        add_action('genesis_after_header', 'topadd0');
    }
    else {
        add_action('genesis_before_loop', 'topadd1');
    }

    That will generate a random value of either 0 or 1, and vary the action depending on that value.

    Thread Starter gabu69

    (@gabu69)

    Wow great

    ty a lot sir ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Randomize an add_action in functions.php to A/B test a Hook’ is closed to new replies.