[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Google Analytics

I am trying to set up Google Analytics for a client and I am using header/footers, my code for my nav system is:


<?php

if (isset($_GET['p']))
{
    $pages = array(
      'testimonials',
      'client-list',
      'articles',
      'products',
      'classes',
      'aging-training',
      'calculating-thr',
      'res-training',
      'design-weightroom',
      'fitness-training',
      'detraining',
      'adapt',
      'classes',
      'contact',
      'cold-weather',
      'core',
      'consultancy',
      'c-core',
      'c-images'
      );

    if (in_array($_GET['p'], $pages))
   {
        // if exists, then include it
        $page=$_GET['p'] ;
   }
   else
  {
        $page='404';
   }
}
else
{
    // default page
    $page='default';
}

if ($page=='default')
{
   $header='header';
}
else
{
   $header='header';
}
include $header.".php";    
include $page.".php";
include 'footer.php';

?>

Under the help section is:

http://www.google.com/support/googleanalytics/bin/answer.py?answer=55504&topic=10981

I am kind of confused how to implement it, any suggestions?

I created the analyticstracking.php like it told me and before </body> I have:

<?php
$virtual_page = "example_page_name_1";
include_once("analyticstracking.php")
?>

Where example_page_name_1 is do I put:

$page

Thanks,

Ryan
0
catonthecouchproductions
Asked:
catonthecouchproductions
  • 5
  • 3
  • 2
1 Solution
 
catonthecouchproductionsAuthor Commented:
So I would have:

<?php
$virtual_page = $page;
include_once("analyticstracking.php")
?>
0
 
frindoCommented:
It needs to be IN the actual HTML of the page. Do header and footer have any html? If not you will have to put it in each individual page in your array or rework the way it grabs the pages. (assuming that each of your pages ends with a </body></html>  tag)
0
 
catonthecouchproductionsAuthor Commented:
It is within the HTML of the page, here is my footer.php file:


</div> <!-- END DIV FOR CONTENT -->
</div> <!-- END DIV FOR WRAPPER -->
<div id="footer">
<img src="images/footer-right.gif" id="footer-right" alt="footer" />
<br /><br />
copyright 2007 vermontfit.com<br />
exercise, performance, health, fitness, science = RESULTS!

</div>
<?php
$virtual_page = $page;
include_once("analyticstracking.php")
?>
</body>
</html>

Is this correct?

$virtual_page = $page;

See how $page is equal to the current page in the array?

Ryan
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
frindoCommented:
Hrmm. Try including it within the <head></head> tags at the top of your pages instead of within the body.
0
 
catonthecouchproductionsAuthor Commented:
I put it in there and checked my view source and have:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">
  _uacct="UA-2411317-13";
  urchinTracker('consultancy');
</script>

The consultancy is the name of the page, so it is pulling that variable from the array.

Ryan
0
 
NovitshCommented:
Of course it is. It's using echo in the source. And not an include or require.

Try putting this in you HEAD tags:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
  _uacct="UA-XXXXXX-X";
  urchinTracker('<?php require($virtual_page); ?>');
</script>
<?php
// End Analytics tracking code
?>
0
 
NovitshCommented:
And don't forget to adjust the UA-XXXXXX-X :-)
0
 
catonthecouchproductionsAuthor Commented:
Hey man,

I have what you have but instead include_once and my UA # is my current one.

Any suggestions?
0
 
NovitshCommented:
That should do the trick...
It should work the way I told you. Otherwise you should instantly mail googleanalytics....
0
 
catonthecouchproductionsAuthor Commented:
Thank you!

Ryan
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now