1

I have some problem to get the Google Analytics to work. I have got a analyticsTracking.php file and this is included on my index.php page like this :

<?php
include("begin.php");
include($subroot . "templateconfig.php");
include($cms['tngpath'] . "genlib.php");
include($cms['tngpath'] . "getlang.php");
include($cms['tngpath'] . "$mylanguage/text.php");
tng_db_connect($database_host,$database_name,$database_username,$database_password) or exit;
include($cms['tngpath'] . "checklogin.php");
//Insert the following lines in your index.php to take advantage of template switching
if($templateswitching && $templatenum) {
include($cms['tngpath'] . "templates/template$templatenum/index.php");
exit;
}
//end of lines to be inserted for template switching
$flags['noicons'] = true;
$flags['noheader'] = true;
tng_header( $text['mnuheader'], $flags );
?>
<!-- "Home Page" (the text for these messages can be found at near the bottom of text.php -->
<h1><?php echo $text['mnuheader']; ?></h1>
<p><strong>Please customize this page!</strong></p> 
<?php include ("analyticsTracking.php"); ?>
</body>
</html>

When looking on the genereted index.html there is no data from the analyticsTracking.php at all? Why?

Pleas note, I am not working with PHP so all this is new to me.

Edit1: Sorry, I am using index.php and not index.html.

Edit2: analyticsTracking.php contains somthing like this :

<script type="text/javascript">
var gaJsHost = ((" https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
} catch(err) {}
</script> <?php
// End Analytics tracking code
?>
asked Oct 27, 2011 at 18:47
4
  • 1
    What does analyticsTracking.php contain? Commented Oct 27, 2011 at 18:49
  • Generated index.html? You're working with PHP, but aren't using it. How do you expect the Google Analytics script to function if it isn't being loaded in your pages? Commented Oct 27, 2011 at 18:49
  • @Blender > Sorry, Im using the index.php. Commented Oct 27, 2011 at 18:52
  • It all looks good to me (except the space between include and () - although that's just my personal preference. What do you get when you turn on errors? error_reporting(E_ALL); Commented Oct 27, 2011 at 18:56

2 Answers 2

1

So if I'm understanding correctly, your index.php script includes analyticsTracking.php, yet when you view index.php in a browser, you don't see any of the HTML from analyticsTracking.php.

<?php include ("analyticsTracking.php"); ?>

Is that the correct path? Is analyticsTracking.php in the same directory as index.php? Try changing the include to a require and see if it prints an error when the webpage is refreshed.

answered Oct 27, 2011 at 18:56
Sign up to request clarification or add additional context in comments.

Comments

1

Sorry, the problem was that I used the wrong php file. It is working as it should.

answered Nov 14, 2011 at 8:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.