Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2012
    Posts
    12
    Plugin Contributions
    0

    Default Google Analytics Question

    Okay, so what I am trying to do is exclude my-self from being recorded by Google Analytics on my own site.

    What I believe will work is as followed:

    Saving the Google Tracking Code into it's own php file (googleanalytics.php) and saving it in the same dir as my html_header.php file.

    Adding the following code to the bottom of html_header.php right before the </head> tag.

    ****127.0.0.1 is just an example of a IP address: (it's not used in the code) and is replaced with my real IP address****

    PHP Code:
    <?php
    $ip_address 
    $ip=$_SERVER['REMOTE_ADDR'];

             if (
    $ip_address != '127.0.0.1')
                include (
    'googleanalytics.php');
            
    ?>
    Will this bypass the Tracking Code if the ip_address is equal to my_ip_address? and then continue down the script after after this check?

    Or

    Would it be more effective if I used
    PHP Code:
    <?php
    $ip_address 
    $ip=$_SERVER['REMOTE_ADDR'];

             if(
    $ip_address '127.0.0.1'
                break;
              else 
                include (
    'googleanalytics.php');
                            

    ?>
    Thanks for any help on this matter, as I am still new to PHP and it's logic.
    Last edited by israelimports; 16 Feb 2012 at 11:03 AM.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,444
    Plugin Contributions
    279

    Default Re: Google Analytics Question

    Have you considered using one of the GA addons?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    May 2010
    Location
    WA State
    Posts
    1,678
    Plugin Contributions
    3

    Default Re: Google Analytics Question

    Just log in to your Google Analytics account and add a filter for your IP address.

  4. #4
    Join Date
    Jan 2012
    Posts
    12
    Plugin Contributions
    0

    Default Re: Google Analytics Question

    Thank you for both responses tho I found the solution to my problem using PHP and desired.

    PHP Code:
    <?php 
    $ip_address 
    $ip=$_SERVER['REMOTE_ADDR']; 
       while(
    $ip_address != 'my_ip_address_here')
       {
            include 
    'googleanalytics.php';
        break;
       }
    ?>
    Thought I'd share in case if anyone was wondering how to do it in PHP with out using an addon or if you work for someone and you don't have access to the analytics account.

  5. #5
    Join Date
    May 2010
    Location
    WA State
    Posts
    1,678
    Plugin Contributions
    3

    Default Re: Google Analytics Question

    Why would anybody want to hack the code when Google provides the option to filter IP addresses and it takes about a minute to do it?

  6. #6
    Join Date
    Jan 2012
    Posts
    12
    Plugin Contributions
    0

    Default Re: Google Analytics Question

    Hack what code? There is no "hacking" involved.

    On top of my site I volunteer my time to a some non-profit organizations and I don't have access to their analytics accounts and well unfortunately just stepping a few of them through signing up for the service was a pain. You don't always have access to simplified tools to do things for you, it's good to know work arounds to those things that otherwise are simple with the proper tools.

 

 

Similar Threads

  1. Google Analytics Question
    By Clan57 in forum All Other Contributions/Addons
    Replies: 5
    Last Post: 14 Oct 2011, 07:17 PM
  2. Google analytics question
    By spleify in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 2 Jun 2011, 10:47 PM
  3. Question about Google Analytics
    By Kryspen in forum General Questions
    Replies: 0
    Last Post: 6 May 2010, 01:06 PM
  4. google analytics question?
    By ian healy in forum General Questions
    Replies: 1
    Last Post: 13 Mar 2009, 11:10 AM

Posting Permissions

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