Last active
February 12, 2022 22:00
-
-
Save Leon2110/281a7e3271aef6df30188bfc72df3709 to your computer and use it in GitHub Desktop.
UTM ЮТМ #php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Функция из ссылки извлекает ютм и отдает массив | |
<?php | |
$requestUrl = 'https://site.ru/?utm_source=yandex&utm_medium=cpc&utm_campaign=context&utm_content=kupit_corobku&utm_term=%D0%BA%D1%83%D0%BF%D0%B8%D1%82%D1%8C+%D0%BA%D0%BE%D1%80%D0%BE%D0%B1%D0%BA%D0%B8+%D0%B4%D0%BB%D1%8F+%D0%BE%D0%B1%D1%83%D0%B2%D0%B8'; | |
function getUTM($url) { | |
$params = []; | |
$utm = []; | |
$params_tmp = parse_url($url); | |
$params_tmp = explode('&', $params_tmp['query']); | |
foreach($params_tmp as $param) { | |
list($key, $val) = array_map('trim', explode('=', $param)); | |
if($key != '' && $val != '') { | |
$params[$key] = $val; | |
$utm[$key] = urldecode($val); | |
} | |
} | |
return $utm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment