Crave: A modern WordPress theme with appetizing aesthetic


Results 1 to 10 of 10

Thread: How to add google analytics to a PHP website??

  1. #1
    Join Date
    Apr 2014
    Posts
    5

    Default How to add google analytics to a PHP website??

    Hi and thanks for your help,

    I am trying to add google analytics to my company's website.
    Last edited by ladydiella; 04-23-2014 at 09:13 AM.

  2. #2
    Join Date
    Apr 2007
    Posts
    15,153

    Default

    I'm a little confused at what you did after you uploaded the PHP file with the tracking code. So did you call up this php file on all your pages? Seems to me you would need an include statement with the new php file too near your header and aboutsub includes. Am I understanding this correctly?

  3. #3
    Join Date
    Apr 2014
    Posts
    5

    Default

    Hi Lisa,

    You are correct, I put the coding for the external PHP file on all the pages.
    Last edited by ladydiella; 04-23-2014 at 09:13 AM.

  4. #4
    Join Date
    Apr 2007
    Posts
    15,153

    Default

    When you reply using the "Advanced" editor here on the forum there's a button for code. You can paste your code between the brackets and the form won't edit it. This is done by design to prevent code from being executed on the forum. But I still don't see the code for the PHP file.

  5. #5
    Join Date
    Apr 2014
    Posts
    5

    Default

    Okay hope this works

    [PHP] Include('header.php');
    Last edited by ladydiella; 04-23-2014 at 09:14 AM.

  6. #6
    Join Date
    Sep 2012
    Location
    Ilkeston, Derbyshire, England
    Posts
    1,785

    Default

    You'd be better just searching YouTube for a video covering this topic. There are dozens of tutorials out there for this sort of thing and if I had sound on my iPad I bet I could find the answer in 10 minutes without having any prior knowledge of your issue.

  7. #7
    Join Date
    Apr 2014
    Posts
    5

    Default

    tried that, Darren. Didn't find what I was looking for.

  8. #8
    Join Date
    Sep 2012
    Location
    Ilkeston, Derbyshire, England
    Posts
    1,785

    Default

    PHP Code:
    <?php
    Include('header.php');
    Include(
    'aboutsub.php');
    ?>
    I'm guessing you need to add Include('analyticstracking.php') as one of your includes in the head of each of your pages. Or maybe you could have an include within an include if you think it through logistically.

  9. #9
    Join Date
    Apr 2014
    Posts
    5

    Default

    The coding post worked (see above), any suggestions on how to get google analytics working?

  10. #10
    Join Date
    Dec 2007
    Location
    Alexandria, MN USA
    Posts
    6,514

    Default

    One thing to do is to add the doctype to the beginning of your code. This will make it easier to check for validation and find errors. For html5 your file should begin:

    Code:
    <!DOCTYPE html>
    <html>
    <head>

    Now, back to the google code. Looking at your site it appears the code is in the head, but the code you posted shows the include put in the body. It should be in the head, preferably at the end.
    Last edited by James; 04-23-2014 at 09:27 AM.
    Good Success!

    Website: Success With Money
    "People will forget what you said, people will forget what you did, but people will never forget how you made them feel." —Maya Angelou

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •