It's not possible to do it only with the HTTP's refereral, because the HTTPS protocol and Google deletes the URL parameters. Also, not so easy as you think, because there is a lot of variations to take in consideration (for example new.google.com, or Google.com)
Google Analytics mixes the referer pages and the UTM_parameters (Gclid is also included). I recomend you take a look of this document for more information
https://support.google.com/analytics/answer/6205762?hl=en
But, I leave you a mini script that can help you, but it works only to detect the Google.
<?php
function detectCampaing()
{
$ret = false;
if(isset($_GET["gclid"])){ $ret = true;}
if(isset($_GET["utm_source"])){ $ret = true;}
if(isset($_GET["utm_medium"])){ $ret = true;}
if(isset($_GET["utm_campaign"])){ $ret = true;}
return $ret;
}
if(detectCampaing() == true ||strpos($_SERVER["HTTP_REFERER"], 'google') !== false){echo "is campaign";}else{echo "is not a campaign";}
?>