Advertisement
vovanx

Ecommerce

Jul 6th, 2020
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 KB | None | 0 0
  1. <?php
  2. $ga = 'GA1.2.1969130287.1593675284';
  3. $payment_id = 462;
  4. $amount = "12.00";
  5. $amount = str_replace(",",".", $amount);
  6.  
  7. $fields = [
  8.     'v'     =>  1,
  9.     't'     =>  'transaction',
  10.     'tid'   =>  'UA-XXXXXXXXX-4',
  11.     'cid'   =>  $ga,
  12.     'ti'    =>  $payment_id,
  13.     'ta'    =>  'cbilling',
  14.     'tr'    =>  $amount,
  15.     'cu'    =>  'RUB'
  16. ];
  17.  
  18. $url = 'https://www.google-analytics.com/collect';
  19. $content = http_build_query($fields);
  20. $content = utf8_encode($content);
  21.  
  22. $ch = curl_init();
  23. curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
  24. curl_setopt($ch, CURLOPT_URL, $url);
  25. curl_setopt($ch,CURLOPT_HTTPHEADER,array('Content-type: application/x-www-form-urlencoded'));
  26. curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
  27. curl_setopt($ch,CURLOPT_POST, TRUE);
  28. curl_setopt($ch,CURLOPT_POSTFIELDS, $content);
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30. curl_exec($ch);
  31. curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement