Search code examples
google-analyticsmeasurement-protocol

Measurement Protocol refund data


I've resolved all issues with sending data, but receive issue when trying to refund.

I've sent this array to measurement protocol :

        'v' => '1',
        'tid' => $tid,
        'cid' => $cid,
        'ti' => '12345', // this transaction exist in google
        't' => 'event',
        'ec'=> 'Ecommerce',
        'ea'=> 'Refund',
        'ni'=> '1',
        'pa'=> 'refund'

But without any result. So my question is what's wrong? Maybe I need some additional call to measurement system, please advice. BTW Google hit debugger return 'valid'.


Solution

  • I've resolve it in this way :

    I've sent new transaction with negative val

                'v' => '1',
                'tid' => $tid,
                'cid' => $cid,
                'ti' => $order,
                't' => 'transaction',
                'tr' => '-'.$order_total
    

    Then send event with negative value

                'v' => '1',
                'tid' => $tid,
                'cid' => $cid,
                'ti' => $order,
                't' => 'item',
                'in' => $product['name'],
                'ip' => '-'.$order_total,
                'ic' => $products['sku'],
                'iq' => -1
    

    And it works, transactions disappear from google reports, btw also want to note that I switch script to use GET ( https://www.google-analytics.com/collect?payload_data& ) instead of POST.