WMWW | Webmaster Forumu | Webmaster Platformu
[PHP] Google Analitik ID Bulucu - Yazdırılabilir Sürüm

+- WMWW | Webmaster Forumu | Webmaster Platformu (https://wmwebworld.com/forum)
+-- Forum: Webmaster Dünyası (https://wmwebworld.com/forum/webmaster-dunyasi)
+--- Forum: Hazır Kodlar (https://wmwebworld.com/forum/hazir-kodlar)
+--- Konu: [PHP] Google Analitik ID Bulucu (/f-php-google-analitik-id-bulucu.html)



[PHP] Google Analitik ID Bulucu - oxcakmak - 08-05-2019

Kodlar:
PHP Kod:
function fetchGoogleAnalyticsUAID($googleAnalyticsURL){
    // Script Regex
    $script_regex "/<script\b[^>]*>([\s\S]*?)<\/script>/i"
    // UA_ID Regex
    $ua_regex "/UA-[0-9]{5,}-[0-9]{1,}/";
    // Preg Match for Script
    // Extract all the script tags of the content
    preg_match_all($script_regexfile_get_contents($googleAnalyticsURL), $inside_script); 
    // Check for ga.gs and _trackPageview in all <script> tag
    for ($i 0$i count($inside_script[0]); $i++){
        if (stristr($inside_script[0][$i], "ga.js")) $flag2_ga_js TRUE;
    }
    // Preg Match for UA ID
    // Extract UA-ID using regular expression
    preg_match_all($ua_regexfile_get_contents($googleAnalyticsURL), $ua_id);
    // Return UA ID
    return $ua_id[0][0];


Kullanımı:
PHP Kod:
echo fetchGoogleAnalyticsUAID("website_url");