I have about 50 pages, each of them contains an include for the header part:
include './include/header.php';
and header.php
contains code such as:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
But now, for about 20 pages I want to conduct Google Experiments, and need to have A/B versions for them.
Google requires that in the original page, I would add an individual block of code for each experiment, right after the <head>
tag:
<head>
//type 1 block of code for page 1 //
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<head>
//type 2 block of code for page 2 //
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
and so on.
What would be the easiest/smartest way to handle this?
EDIT:
Ok, I think I should edit header.php
to look like this:
<!DOCTYPE html>
<html>
<head>
<?php if ($experiment==true) { ?> // New
[some way to insert block of code ] // New
<?php } else { } ?> // New
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta charset="utf-8">
<title><?php echo $title; ?></title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
And in every individual page that should have an experiment, I would add this code at top of page:
$experiment = "big block of code 1"
But how exactly do I do it?