Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6113265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:50:20+00:00 2026-05-23T14:50:20+00:00

I was trying to store the Google Analytics code in a single file that

  • 0

I was trying to store the Google Analytics code in a single file that all scripts reference. But my file seems to be breaking the analytics code, and none of the pages that use this file show up in my google analytics report anymore.

Here is what I did in the head section of the scripts:

<?php
include ('global.php');
include ('connect.php');
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
    "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html>
<head>

<?php
printGoogleAnalytics();
?>


<?php
printGoogleSiteVerification();
?>

</head>

Here is what the printGoogleAnalytics() looks like in global.php :

function printGoogleAnalytics()
{
    if($production === true)
    {
$str = <<<EOT
        <script type="text/javascript">
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-9425856-20']);
        _gaq.push(['_trackPageview']);

           (function() {
           var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
           ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
           var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
           })();
        </script>


EOT;
    echo $str;
    }
}

Any idea what may be breaking things? Is there any other code needed from me? I use PHP for this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:50:20+00:00Added an answer on May 23, 2026 at 2:50 pm

    Since the Google Analytics code wasn’t appearing in the source of the generated page, it means that that block isn’t getting evaluated.

    The likeliest suspect is if($production===true). Using 3 equals signs means its a STRICT comparison. What’s probably happening is you’re not setting it precisely to true, but instead to something that’s kind of truthy.

    You could get around that by either fixing how $production gets set, or using ==.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to store my Google Maps API Key in my application.ini file,
I'm trying to store a password in a file that I'd like to retrieve
I'm trying this code I found with google, but it didn't connect to my
I am trying to use a property file to store my google checkout merchant
I trying out some problems in Google's Code Jam. For the question Store Credit
I'm trying to store Django data on MS SQL Server 2005 using: http://code.google.com/p/django-pyodbc/ (pyodbc
I'm trying to develop a Store Locator (using Google Maps v3 API), that's located
I'm facing a problem that Google couldn't solve yet! I'm trying to store URLs
I'm trying to store an xml serialized object in a cookie, but i get
I am trying to store an xml value in my app.config file. The app.config

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.