How to install Google Analytic at WeBid?

Discussion in 'General Support' started by artlauk, Apr 25, 2012.

  1. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    Hello there!

    Does any have experience with google analytic installing in webid site?

    In GA help page there is mentioned:

    "For any PHP pages, put the following code in a file (for example, analyticstracking.php) and upload it to your site. Then, add the following line to each template page immediately after the opening <body> tag: <?php include_once("analyticstracking.php") ?>"

    I made this analyticstracking.php file but does I really need to put this include_once("analyticstracking.php") in every php file? Or I can put it on some general tpl file?

    And file need to be write as:
    include_once("analyticstracking.php") OR
    include_once 'analyticstracking.php';

    At the moment I put in index.php:

    include 'includes/common.inc.php';
    include $main_path . 'language/' . $language . '/categories.inc.php';
    include_once 'analyticstracking.php';

    under the:
    include 'includes/common.inc.php';
    include $main_path . 'language/' . $language . '/categories.inc.php';

    if I put it before:
    include 'includes/common.inc.php';
    include $main_path . 'language/' . $language . '/categories.inc.php';

    than there is showing some error at index.php page loading about that already this information is sent to somewhere and can't get send twice!

    ?HELP?

    thanks!
     
  2. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    I thought you get like a bit of code to add to your site.
    Html code with some script.
    You would open the footer.tpl and add it near the end. Then it would be in every page you have.
    Have a look on GA for the script. Haven't been on GA for a while so do not know what they give you now.
     
  3. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    thanks, pani100 for answer.

    but if I add it to footer.tpl than it will count every time when somebody reset page? so it means that one user come to site and go around it for example using some 20 pages in abcd.lv directory - then GA will count all times as visitors? Or it will count only first visit time?

    Also if I add it to footer.tpl than in analytic reports it will show as /index.php or also for example /a.php 2 visits; /b.php 5 visits; /c.php 1 visits etc.???

    tracking code sample check at printscreen attachment!
     

    Attached Files:

  4. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    Hi artlauk,
    it will count how many pages the user has gone to.
    But it will be for that user only. It will count him as 1 visitor.
    It needs to be in every page so they can record all the activity on your site.
    The script is very clever and sorts everything out for you.
    It should record each page as it is as they go through your site.
     
  5. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    thanks pani100!

    BUT that's mean at footer.tpl I need install all script or I need use analyticstracking.php file and at footer.tpl only add line include_once("analyticstracking.php")???
     
  6. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    just use the script and add it to the tpl file as far down as you can
     
  7. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    It is not working at all!
     
  8. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,561
    Likes Received:
    134
    Not sure where you got the .php file. Usually you just sign up for a Google Analytics account and generate code like this:

    <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'YOUR GOOGLE ACCOUNT NUMBER']);
    _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>

    That you put in your header or footer. Easiest method. Google is smart enough to count unique visitors.
     
  9. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    ok, ok but i put it in header/footer php file or tpl file?
     
  10. Box Lot

    Box Lot Super Moderator Staff Member Developer

    Joined:
    Dec 18, 2008
    Messages:
    2,561
    Likes Received:
    134
    /themes/YOUR THEME/global_header.php. Just put before your </head> tag.
     
  11. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    ok, thanks a lot for suggestion!

    at the moment I added it to /footer.php

    <?php
    /***************************************************************************
    * copyright : (C) 2008, 2009 WeBid
    * site : http://www.webidsupport.com/
    ***************************************************************************/

    /***************************************************************************
    * This program is free software; you can redistribute it and/or modify
    * it under the terms of the GNU General Public License as published by
    * the Free Software Foundation; either version 2 of the License, or
    * (at your option) any later version. Although none of the code may be
    * sold. If you have been sold this script, get a refund.
    ***************************************************************************/
    include_once("analyticstracking.php");

    $template->assign_vars(array(
    'L_COPY' => empty($system->SETTINGS['copyright']) ? '' : '<p>' . $system->SETTINGS['copyright'] . '</p>',



    'B_VIEW_TERMS' => ($system->SETTINGS['terms'] == 'y'),
    'B_VIEW_PRIVPOL' => ($system->SETTINGS['privacypolicy'] == 'y'),
    'B_VIEW_ABOUTUS' => ($system->SETTINGS['aboutus'] == 'y'),
    'B_FEES' => ($system->SETTINGS['fees'] == 'y')
    ));

    $template->set_filenames(array(
    'footer' => 'global_footer.tpl'
    ));
    $template->display('footer');


    // if the page has loaded OK you dont need this data anymore :)
    unset($_SESSION['SESSION_ERROR']);
    ?>

    and it looks working fine!
     
    j2000 likes this.
  12. j2000

    j2000 New Member

    Joined:
    Apr 29, 2012
    Messages:
    38
    Likes Received:
    0
    I try , this is correct step ?

    1: i create from "google analytic code" .txt and rename to analyticstracking.php ,
    <script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-11111111-1']);
    _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>

    2: Edit footer.php , add text : include_once("analyticstracking.php");

    3: reUpload footer.php and analyticstracking.php

    This is correct ?

    Regards

    Joel
     
  13. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    yes, I think it is.

    To check it, you can go to your site in one tab and in new tab open google analytic real time view and check if you are shown as visitor.
     
  14. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    hi j2000,
    you can also just put the complete code:
    <script>
    ......your script ....
    </script>

    in your footer.tpl file
     
  15. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    -> pani100

    With footer.tpl --> you mean /themes/default/global_footer.tpl because there isn't footer.tpl is for admin section not user?!
    I put it to try /themes/default/global_footer.tpl but it is not working for me! So better I think is stay at footer.php like I write before.
     
  16. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    artlauk,
    Yes in your theme that you are using footer.tpl,
    I have added a few different things there like piwik and feedjit script.
    If I was to add goggle analytic script that's where I would put it too.
    If yours works with the include_once("analyticstracking.php"); in the footer.php that's fine though too.
     
    j2000 likes this.
  17. artlauk

    artlauk New Member

    Joined:
    Apr 13, 2012
    Messages:
    60
    Likes Received:
    1
    but footer.tpl is under admin section, so I believe this is load only when someone log in as administrator! It is not loading when someone standard user are viewing page.
     
  18. pani100

    pani100 Well-Known Member

    Joined:
    May 9, 2011
    Messages:
    2,032
    Likes Received:
    362
    Sorry artlauk,
    my mistake, that is global_footer.tpl in the theme that you are using folder.
    your site/themes/your theme/global_footer.tpl
     

Share This Page