Get rid of Facebook ugly FBCLID and unwanted parameter

The first time I noticed this ugly parameter in the links that sent to my website was when the links did not work, because the website was not developed for the GET parameters!

Then I realized that all the links I put on Facebook had attached this fbclid parameter, which I do not need in websites, nor do I want to help Facebook giant to collect more information and make more money on the basis of my content when I have no real benefit from them. If Facebook want this link to be on my website, then I want to have a similar benefit, at least a better visibility of the shared links !

The fbclid parameter will track who the user is and match it back to fb ads = more money for them not for us. Nowadays, if you do not pay promotion for facebook pages, not even 1% of those who are friends will see posts, others never-ever!

Coding, Programming, Scripts, LanguageSo, I did myself a script that helps me get rid of this useless parameter and that crashes my server cache, because the websites must serve real-time information (if the get parameters are present), which means that my resources are being wasted for the benefit of big corporations. I mean, I pay for hosting from my pocket, so facebook can sell her ads!

The code is somewhat more laborious because I developed it with the intention of eliminating other parameters that abusiveinformation collectors” will invent in the future.

Use the code below in the first website file, usually index.php!

  /** 
    * @desc Removes unwanted parameters from the url address
    * @author Emilian Robert Vicol byrev yahoo.com	
    * @param parameters name 
    * @return redirect to clean url !
  */ 	
  function byrev_filter_remove_request($param='') {
    
    if (empty($param)) 
      return;

    if (!is_array($param))
      $param = array($param);

    $pageURL0 = (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on') ? "https://" : "http://";		
    $pageURL1 = $pageURL0 . $_SERVER["SERVER_NAME"];
    $pageURL2 = $pageURL1 . $_SERVER["REQUEST_URI"];
    
    $url_data = parse_url($pageURL2);

    parse_str($url_data['query'], $get);
    
    foreach ($param as $p)
      unset($get[$p]);
    
    $new_query = http_build_query($get);
    
    $preq = ($new_query != "") ? "?" : "";
    
    $clean_url = $url_data['scheme'].'://'.$url_data['host'].$url_data['path'].$preq.$new_query;

    header("Location: $clean_url");
    exit;
    
  }
  
  
  global $_BYREV_TRAKING_UNWANTED;
  $_BYREV_TRAKING_UNWANTED = array(
    'facebook' => 'fbclid',
    'google' => 'gclid',
    //'utm_source' => 'utm_source',
    //'utm_campaign' => 'utm_campaign',
    //'utm_content' => 'utm_content',
    //'tm_term' => 'tm_term',
    //'utm_medium' => 'utm_medium',
  );	
    
  /** 
    * @desc Check if the url has an unwanted parameter
    * @author Emilian Robert Vicol byrev yahoo.com	
    * @param arra with paramenters name 
    * @return redirect to clean url !
  */ 		
  function byrev_filter_check_request() {
  
    global $_BYREV_TRAKING_UNWANTED;
    
    foreach ($_BYREV_TRAKING_UNWANTED as $unwanted) {
      if (isset($_GET[ $unwanted ])) {
        byrev_filter_remove_request( $_BYREV_TRAKING_UNWANTED );
      }
    }		
    
  }
  
  // ~~ Check if the url has an unwanted parameter
  byrev_filter_check_request();

 

byrev Written by:

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *