I am new to PHP but learning slowly. Problem I have is including Google Analytics in my header.
I have created a separate php file for the code but my issue is including this in the PHP HEADER file below:
I believe that the issue is the @$content[1] .=’ tag – but I need to include this as this is how my site is built.
How would I put the Google Analytics code before the tag without confusing the php code in the file.
Thanks in advance. (I would ask my developer but I want to learn myself).
HEADER FILE PHP CODE BELOW:
<?php
@$content[1] .='
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html lang="en" dir="ltr">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Title</title>
<link id="www-core-css" rel="stylesheet" href="template/css/core.css">
<link id="www-core-css" rel="stylesheet" href="template/css/style.css">
</script></head>
<body>
<div id="page" class=""> </div>
<div id="masthead-container">
<div id="masthead" class="">
<a href="index.php">
<button id="logo" class="master-sprite" title="Online ePub Builder"></button>
</a>
<div align="right">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-6078741672481332";
/* UK 1 */
google_ad_slot = "5428463210";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>';
if(is_login()) {
$content[1] .='<div id="masthead-utility">
Hello, <a href="user.php">'.$_SESSION['uidrealname'].'</a>
<a href="logout.php">Sign Out</a>
</div>';
} else {
$content[1] .='<div id="masthead-utility">
<a href="login.php">Create Account</a>
or
<a href="login.php">Sign In</a>
</div>';
}
$content[1] .=' <div id="masthead-nav-user">
<a href="help.php">Help</a>
<a href="guide.php">FREE Guide</a>
</div>
<div id="masthead-nav-main">
<a href="new.php">New Book</a>
'.(is_login() ? '<a href="books.php? u='.$_SESSION['uid'].'">My Books</a>' : '').'
</div>
<div id="masthead-end"></div>
</div>
</div>
<div id="baseDiv">
<div id="homepage-main-content" class="">';
?>
Get the file content:
Then just add this into your string just before the end of your head like so: