Google Analytics and php

Discussion in 'AdSense' started by qawsedrf, Dec 20, 2008.

  1. #1
    Ive just signed up for google analytics and its telling me to put the analytic code just before </body>. I cant find the tag in my php file so how exactly do i put the script into it?
     
    qawsedrf, Dec 20, 2008 IP
  2. M3rC

    M3rC Peon

    Messages:
    1,493
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    it should be in your footer.php file :)

    If there isn't a body tag, just copy the code to the very bottom and insert "</body></html>" after it.

    works fine for me :)
     
    M3rC, Dec 20, 2008 IP
  3. lomazoma

    lomazoma Active Member

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #3
    if u use forum i thing the best way to put in in 1st line in header style
     
    lomazoma, Dec 20, 2008 IP
  4. qawsedrf

    qawsedrf Guest

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I tried putting in the script and then the ending tags but it still didnt work.
    I tried putting the starting tags infront of it aswell.
     
    qawsedrf, Dec 20, 2008 IP
  5. lomazoma

    lomazoma Active Member

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #5
    what kind script u running???
     
    lomazoma, Dec 20, 2008 IP
  6. qawsedrf

    qawsedrf Guest

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    im trying to put this
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-6750913-1";
    urchinTracker();
    </script>
    Code (markup):
    into this
    <?php
    /*******************************************************************
    * Glype Proxy Script
    *
    * Copyright (c) 2008, http://www.glype.com/
    *
    * Permission to use this script is granted free of charge
    * subject to the terms displayed at http://www.glype.com/downloads
    * and in the LICENSE.txt document of the glype package.
    *******************************************************************
    * This file is the webroot index.php and displays the proxy form.
    * Nothing too complicated - decode any errors, render relevant
    * options taking into account forced/defaults.
    ******************************************************************/
    
    /*****************************************************************
    * Initialise the application
    ******************************************************************/
    
    // Load global file
    require 'includes/init.php';
    
    // Send our no-cache headers
    sendNoCache();
    
    // Start the output buffer
    ob_start('render');
    
    // Flag valid entry point for hotlink protection
    $_SESSION['no_hotlink'] = true;
    
    
    /*****************************************************************
    * Determine the options to display
    ******************************************************************/
    
    // Start with an empty array
    $toShow = array();
    
    // Loop through the available options
    foreach ( $CONFIG['options'] as $name => $details ) {
    
    	// Check we're allowed to choose
    	if ( ! empty($details['force']) ) {
    		continue;
       }
    
       // Generate the HTML 'checked' where appropriate
       $checked = $options[$name] ? ' checked="checked"' : '';
       
       // Add to the toShow array
    	$toShow[] = array('name'         => $name,
                         'title'        => $details['title'],
                         'desc'         => $details['desc'],
                         'escaped_desc' => str_replace("'", "\'", $details['desc']),
                         'checked'      => $checked);
    
    }
    
    
    /*****************************************************************
    * Look for any error information in the URL.
    ******************************************************************/
    
    // Check for error
    if ( isset($_GET['e']) && isset($phrases[$_GET['e']]) ) {
    
    	// Look for additional arguments (to be used as variables in the error message)
    	$args = isset($_GET['p']) ? @unserialize(base64_decode($_GET['p'])) : array();
       
       // If we failed to decode the arguments, reset to a blank array
    	if ( ! is_array($args) ) {
    		$args = array();
       }
       
    	// Did we find any args to pass?
    	if ( $args ) {
       
    		// Add phrase to start of array (to give to call_user_func_array())
    		$args = array_merge( (array) $phrases[$_GET['e']], $args);
    		$error = call_user_func_array('sprintf',$args);
    	
       } else {
       
          // Just a simple print
    		$error = $phrases[$_GET['e']];
          
    	}
       
    	// Finally add it to the $themeReplace array to get it in there
    	$themeReplace['error'] = '<div id="error">' . $error . '</div>';
       
       // And a link to try again?
       if ( ! empty($_GET['return']) ) {
          $themeReplace['error'] .= '<p style="text-align:right">[<a href="' . $_GET['return'] . '">Reload ' . deproxifyURL($_GET['return']) . '</a>]</p>';
       }
       
    }
    
    /*****************************************************************
    * Check PHP version
    ******************************************************************/
    
    if ( version_compare(PHP_VERSION, 5) < 0 ) {
       $themeReplace['error'] = '<div id="error">You need PHP 5 to run this script. You are currently running ' . PHP_VERSION . '</div>';
    }
    
    
    /*****************************************************************
    * Maintenance - check if we want to do anything now
    ******************************************************************/
    
    if ( $CONFIG['tmp_cleanup_interval'] ) {
       
       // Do we have a next run time?
       if ( file_exists($file = $CONFIG['tmp_dir'] . 'cron.php') ) {
       
          // Load the next runtime
          include $file;
          
          // Compare to current time
          $runCleanup = $nextRun <= $_SERVER['REQUEST_TIME'];
          
       } else {
       
          // No runtime stored, assume first request with the cleanup option
          // enabled so run now.
          $runCleanup = true;
                
       }
       
       // This might take a while so do it after user has received
       // page and cut connection.
       if ( ! empty($runCleanup) ) {
          header('Connection: Close');
       }
    
    }
    
    
    /*****************************************************************
    * All done, show the page
    ******************************************************************/
    
    // Throw all template variables into an array to pass to the template
    $vars['toShow'] = $toShow;
    
    echo loadTemplate('main', $vars);
    
    // And flush buffer
    ob_end_flush();
    
    
    /*****************************************************************
    * Now actually do the maintenance if desired
    ******************************************************************/
    
    if ( ! empty($runCleanup) ) {
    
       // Don't stop
       ignore_user_abort(true);
    
       // Update the time file
       file_put_contents($file, '<?php $nextRun = ' . ( $_SERVER['REQUEST_TIME'] + round(3600 * $CONFIG['tmp_cleanup_interval']) ) . ';');
    
       // All set, start cleaning! First, empty the cache.
       if ( is_dir($CONFIG['cache_path']) && ( $handle = opendir($CONFIG['cache_path']) ) ) {
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             // Delete it
             unlink($CONFIG['cache_path'] . $file);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // Next, remove old cookie files
       if ( is_dir($CONFIG['cookies_folder']) && ( $handle = opendir($CONFIG['cookies_folder']) ) ) {
       
          // Cut off for "active" files (24 hours)
          $cutOff = $_SERVER['REQUEST_TIME']-86400;
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             $path = $CONFIG['cookies_folder'] . $file;
             
             // Check it's not being used
             if ( filemtime($path) > $cutOff ) {
                continue;
             }
             
             // Delete it
             unlink($path);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // And finally, remove logs
       if ( $CONFIG['tmp_cleanup_logs'] && is_dir($CONFIG['logging_destination']) && ( $handle = opendir($CONFIG['logging_destination']) ) ) {
       
          // Cut off for deletion of old logs
          $cutOff = $_SERVER['REQUEST_TIME'] - ($CONFIG['tmp_cleanup_logs'] * 86400);
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             $path = $CONFIG['logging_destination'] . $file;
             
             // Check it's not being used
             if ( filemtime($path) > $cutOff ) {
                continue;
             }
             
             // Delete it
             unlink($path);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // Finished.
    
    }
    Code (markup):
     
    qawsedrf, Dec 20, 2008 IP
  7. lomazoma

    lomazoma Active Member

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #7
    you can put at 1st line

    <head>
    </head>
    <body>
    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    _uacct = "UA-6750913-1";
    urchinTracker();
    </script>
    </body>
    </html>
    <?php
    /*******************************************************************
    * Glype Proxy Script
    *
    * Copyright (c) 2008, http://www.glype.com/
    *
    * Permission to use this script is granted free of charge
    * subject to the terms displayed at http://www.glype.com/downloads
    * and in the LICENSE.txt document of the glype package.
    *******************************************************************
    * This file is the webroot index.php and displays the proxy form.
    * Nothing too complicated - decode any errors, render relevant
    * options taking into account forced/defaults.
    ******************************************************************/
    
    /*****************************************************************
    * Initialise the application
    ******************************************************************/
    
    // Load global file
    require 'includes/init.php';
    
    // Send our no-cache headers
    sendNoCache();
    
    // Start the output buffer
    ob_start('render');
    
    // Flag valid entry point for hotlink protection
    $_SESSION['no_hotlink'] = true;
    
    
    /*****************************************************************
    * Determine the options to display
    ******************************************************************/
    
    // Start with an empty array
    $toShow = array();
    
    // Loop through the available options
    foreach ( $CONFIG['options'] as $name => $details ) {
    
    	// Check we're allowed to choose
    	if ( ! empty($details['force']) ) {
    		continue;
       }
    
       // Generate the HTML 'checked' where appropriate
       $checked = $options[$name] ? ' checked="checked"' : '';
       
       // Add to the toShow array
    	$toShow[] = array('name'         => $name,
                         'title'        => $details['title'],
                         'desc'         => $details['desc'],
                         'escaped_desc' => str_replace("'", "\'", $details['desc']),
                         'checked'      => $checked);
    
    }
    
    
    /*****************************************************************
    * Look for any error information in the URL.
    ******************************************************************/
    
    // Check for error
    if ( isset($_GET['e']) && isset($phrases[$_GET['e']]) ) {
    
    	// Look for additional arguments (to be used as variables in the error message)
    	$args = isset($_GET['p']) ? @unserialize(base64_decode($_GET['p'])) : array();
       
       // If we failed to decode the arguments, reset to a blank array
    	if ( ! is_array($args) ) {
    		$args = array();
       }
       
    	// Did we find any args to pass?
    	if ( $args ) {
       
    		// Add phrase to start of array (to give to call_user_func_array())
    		$args = array_merge( (array) $phrases[$_GET['e']], $args);
    		$error = call_user_func_array('sprintf',$args);
    	
       } else {
       
          // Just a simple print
    		$error = $phrases[$_GET['e']];
          
    	}
       
    	// Finally add it to the $themeReplace array to get it in there
    	$themeReplace['error'] = '<div id="error">' . $error . '</div>';
       
       // And a link to try again?
       if ( ! empty($_GET['return']) ) {
          $themeReplace['error'] .= '<p style="text-align:right">[<a href="' . $_GET['return'] . '">Reload ' . deproxifyURL($_GET['return']) . '</a>]</p>';
       }
       
    }
    
    /*****************************************************************
    * Check PHP version
    ******************************************************************/
    
    if ( version_compare(PHP_VERSION, 5) < 0 ) {
       $themeReplace['error'] = '<div id="error">You need PHP 5 to run this script. You are currently running ' . PHP_VERSION . '</div>';
    }
    
    
    /*****************************************************************
    * Maintenance - check if we want to do anything now
    ******************************************************************/
    
    if ( $CONFIG['tmp_cleanup_interval'] ) {
       
       // Do we have a next run time?
       if ( file_exists($file = $CONFIG['tmp_dir'] . 'cron.php') ) {
       
          // Load the next runtime
          include $file;
          
          // Compare to current time
          $runCleanup = $nextRun <= $_SERVER['REQUEST_TIME'];
          
       } else {
       
          // No runtime stored, assume first request with the cleanup option
          // enabled so run now.
          $runCleanup = true;
                
       }
       
       // This might take a while so do it after user has received
       // page and cut connection.
       if ( ! empty($runCleanup) ) {
          header('Connection: Close');
       }
    
    }
    
    
    /*****************************************************************
    * All done, show the page
    ******************************************************************/
    
    // Throw all template variables into an array to pass to the template
    $vars['toShow'] = $toShow;
    
    echo loadTemplate('main', $vars);
    
    // And flush buffer
    ob_end_flush();
    
    
    /*****************************************************************
    * Now actually do the maintenance if desired
    ******************************************************************/
    
    if ( ! empty($runCleanup) ) {
    
       // Don't stop
       ignore_user_abort(true);
    
       // Update the time file
       file_put_contents($file, '<?php $nextRun = ' . ( $_SERVER['REQUEST_TIME'] + round(3600 * $CONFIG['tmp_cleanup_interval']) ) . ';');
    
       // All set, start cleaning! First, empty the cache.
       if ( is_dir($CONFIG['cache_path']) && ( $handle = opendir($CONFIG['cache_path']) ) ) {
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             // Delete it
             unlink($CONFIG['cache_path'] . $file);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // Next, remove old cookie files
       if ( is_dir($CONFIG['cookies_folder']) && ( $handle = opendir($CONFIG['cookies_folder']) ) ) {
       
          // Cut off for "active" files (24 hours)
          $cutOff = $_SERVER['REQUEST_TIME']-86400;
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             $path = $CONFIG['cookies_folder'] . $file;
             
             // Check it's not being used
             if ( filemtime($path) > $cutOff ) {
                continue;
             }
             
             // Delete it
             unlink($path);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // And finally, remove logs
       if ( $CONFIG['tmp_cleanup_logs'] && is_dir($CONFIG['logging_destination']) && ( $handle = opendir($CONFIG['logging_destination']) ) ) {
       
          // Cut off for deletion of old logs
          $cutOff = $_SERVER['REQUEST_TIME'] - ($CONFIG['tmp_cleanup_logs'] * 86400);
       
          // Read every file in the cache dir
          while ( ( $file = readdir($handle) ) !== false ) {
          
             // Skip dot files
             if ( $file[0] == '.' ) {
                continue;
             }
             
             $path = $CONFIG['logging_destination'] . $file;
             
             // Check it's not being used
             if ( filemtime($path) > $cutOff ) {
                continue;
             }
             
             // Delete it
             unlink($path);
          
          }
          
          // And close handle
          closedir($handle);
       
       }
       
       // Finished.
    
    }
    
    PHP:
     
    lomazoma, Dec 20, 2008 IP
  8. config_error

    config_error Well-Known Member

    Messages:
    1,719
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    130
    #8
    try to put the code in the first line
    Put The Code Here
    <?php
    /*******************************************************************
    * Glype Proxy Script

    Note: if you have footer.php you can just put it there. in the first line before <?php
     
    config_error, Dec 20, 2008 IP
  9. qawsedrf

    qawsedrf Guest

    Messages:
    128
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Ok i did what you told me and the site is still running. I think its worked but i just need to wait for google to verify.
    Thanks for the help
     
    qawsedrf, Dec 20, 2008 IP
  10. lomazoma

    lomazoma Active Member

    Messages:
    56
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    93
    #10
    u r welcome
    u can verify it use button "Check"in your google analysis
     
    lomazoma, Dec 20, 2008 IP
  11. becoolufull

    becoolufull Banned

    Messages:
    151
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    try another script. The Second One They Give.
     
    becoolufull, Dec 21, 2008 IP