0

In my site I had a Google Analytics Universal tracking code, which generates a some request go google .gif file with this parameters:

enter image description here

How can I parse all parameters from Query String Parameters or just all of parameters which a requested from .gif file cUrl?

URL example:

curl 'http://www.google-analytics.com/collect?v=1&_v=j16&a=589794211&t=pageview&_s=1&dl=http%3A%2F%2Fmellowkids.ru%2Fserv-ga%2Ftest.php%3Futm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_term%3Dkeyword%26utm_content%3Dadstext%26utm_campaign%3Dcampaignname&ul=ru&de=UTF-8&sd=24-bit&sr=1920x1080&vp=1563x436&je=1&fl=12.0%20r0&_u=MAC~&cid=1374804136.1392407945&tid=UA-44059933-1&z=743339889' -H 'Accept: image/webp,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Referer: http://mellowkids.ru/serv-ga/test.php?utm_source=google&utm_medium=cpc&utm_term=keyword&utm_content=adstext&utm_campaign=campaignname' -H 'Accept-Language: en-US,en;q=0.8,ru;q=0.6' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36' --compressed
Konstantin Rusanov
  • 6,414
  • 11
  • 42
  • 55

1 Answers1

2

You can use the parse_str function.

Wayne Whitty
  • 19,513
  • 7
  • 44
  • 66
  • i'm newbie in php, can you write a simple code, how a can parse this cUrl? – Konstantin Rusanov Feb 14 '14 at 21:49
  • Explode past ? and run the query string through parse_str. Use var_dump to debug. – Wayne Whitty Feb 14 '14 at 22:00
  • I do not understand how I pick up (grab) this link from the browser (from DOM). How to parse it through parse_str, not so important. – Konstantin Rusanov Feb 14 '14 at 22:05
  • You could check what scripts are being called: http://stackoverflow.com/questions/2976651/javascript-how-do-i-get-the-url-of-script-being-called – Wayne Whitty Feb 14 '14 at 22:12
  • I dont understand code in your link. If i visit my test page mellowkids.ru/serv-ga/test.php Google Analytics will make a cUrl request to his .gif file (You can see it in the Developer Tools in Chrome). How i can grab this curl, put in variable and prin it via echo()? – Konstantin Rusanov Feb 14 '14 at 22:23
  • basically, Google Analytics takes all parameters from this string from client. It means, that you can get this parameters like user browser, browser language or something else directly from the user. So what parameters do you need? – Bogdan Solomykin Feb 14 '14 at 22:48