1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to add analytics code into PHP website

Discussion in 'Google Analytics' started by 7sk, Feb 23, 2012.

  1. #1
    I want to put analytics code to my website but in my cpanel, I have only 3 editable files, index.php , config.php and php.ini
    SEMrush
    now kindly let me know where I have to put google analytics code?

    no one of these three has <\head> tag :D
     
    7sk, Feb 23, 2012 IP
    SEMrush
  2. M8INTERNET

    M8INTERNET Member

    Messages:
    95
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #2
    You need to locate the template files, usually in the /templates folder
    It should be enough to edit the header.tpl file
    If you want to track the Admin visits, repeat for the /admin folder

    You will then need to apply the correct code or use the {literal} tag
     
    M8INTERNET, Feb 23, 2012 IP
  3. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    there is no template folder.

    I want to track traffic
     
    7sk, Feb 23, 2012 IP
  4. seolabs

    seolabs Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Put the code on index.php
     
    seolabs, Feb 23, 2012 IP
  5. ShivJaiswaL

    ShivJaiswaL Banned

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    50
    #5
    You can download a file(sript provided while google analytic sign up ) to desktop and upload it directly to file maneger . Its the easiest method to add google Analytics and Webmaster tools .
     
    ShivJaiswaL, Feb 23, 2012 IP
  6. themetribe

    themetribe Peon

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can put the tracking code in your index file.
    Its something 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>

    Change the code UA-XXXXXX to your own UA number.

    Regards
     
    themetribe, Feb 23, 2012 IP
  7. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7
    I have completed this step, successfully, downloaded that file and uploaded to main directory.
     
    7sk, Feb 23, 2012 IP
  8. 7sk

    7sk Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #8
    I have copied this code, but not getting how to paste it and where to paste it, kindly tell me the specific location to paste it. when I copied this code, I got the instruction to paste it before closing </head> tag. But I am unable to find this code in all files, index.php. config.php and php.ini


    I think I have to customize some file and put this <head></head> manually, but what would be exact code for it?
     
    7sk, Feb 23, 2012 IP
  9. firebloger

    firebloger Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    You'd better paste this code before </body> tag. And if you don't use templates, then you have to paste this code on every page of your site.
     
    firebloger, Feb 25, 2012 IP
  10. satish nandanwar

    satish nandanwar Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Find index.php file and edit this html code.
     
    satish nandanwar, Mar 15, 2012 IP
  11. Shirley1874

    Shirley1874 Peon

    Messages:
    559
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Now do not need to copy the HTML code any more,just put your GA code into the right place in your settings<Google Analytics Web Property ID.
     
    Shirley1874, Mar 15, 2012 IP
  12. silvios

    silvios Peon

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    what does the index.php file look like? and do u have a setting for GA, what is ur site software?
     
    silvios, Mar 20, 2012 IP
  13. ronaldlee

    ronaldlee Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    put the code in footer part.
     
    ronaldlee, Mar 21, 2012 IP
  14. drues1986

    drues1986 Active Member

    Messages:
    61
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    68
    #14
    still use analytics when google tag manager support analytics try to use tag manager and insert analytics code in tag manager.
     
    drues1986, Dec 8, 2015 IP
  15. PROtechSoft

    PROtechSoft Active Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    #15
    Is your website ready?
     
    PROtechSoft, Jan 24, 2016 IP