Use GA's Measurement Protocol

Business Benefits

Get more accurate data in your Google Analytics and improve analysis.


Export user IDs and dates from Google Analytics into a Google Sheets file.

  • Go to your data report, click Export and select Google Sheets or Excel format.
  • Download data from your website that contains transaction ID’s and revenue per client to another file.
  • Open both Google Sheets and merge the transactions ID of a user and the revenue per user.
  • Use the formula IF(COUNTIF(A:A,A2)=1,0,1) to identify duplicate values.
  • Filter out any transactions that already exist in Google Analytics and contain the value 0.

Create a new column in the spreadsheet, where you add the standard request parameters that collect data for Google Analytics.

Use the Google Analytics Measurement Protocol Parameter Reference guide to format your cURL request link. Your code should look similar to this:

curl --data “v=1&t=event&tid=UA-12345678-9&cid=4482823862.6262588120&ec=measurement+protocol&ea=transaction&el=usView&pa=purchase&ti=trans2&tr=75&cu=USD&ni=1” https://www.google-analytics.com/collect

Finish the new data set by uploading values for each parameter into Google Sheets that can be converted into Google Analytics.

Create a new column for URL, GAID, CID, Event, ProductAction, Noninteraction, and Currency. Open Google Analytics network console, and copy the code for each of the fields into your spreadsheet.

Upload the new data into Google Analytics by opening the terminal or GIT Bash, copy the code that was generated and run the command.

Select Reports > Real-Time, and confirm if the data has been added successfully. You can now analyze all existing data into Google Analytics.

Adjust duplicate purchase data in Google Analytics by exporting data in four columns and include the following: Transaction ID, Transactions, Revenue, and Client ID.

Add the new data in the spreadsheet in separate columns. In the same sheet, create a filter for transactions and filter by condition greater than 1. Create a new column titled Reverse Amount, and in a row add the formula Revenue - (Revenue/Transactions))*-1.

Add the new formatting code to Google Sheets to include all event parameters and values.

  • Match your sheet-spread to the below sheet’s structure. Which includes columns for Transaction ID, Revenue, Remove, URL, GAID, CID, Event, Product/Action, Noninteraction, Currency, Transactions, Reverse amount and Request.
  • Identify the new parameter code for Transactions and Reverse amount in the parameter guide and add it to the code
  • Repeat the same process of running the code in the console and add data into Google Analytics.

Send refund data to Google Analytics by exporting User ID data and their transactions into a spreadsheet or Google Sheets.

Use the same template as in Adjusting Duplicate transaction and create a new column titled Product Action.

Name the code for each user you assign a refund as PA=refund. Add the new parameter and the value to the previous code to create a new code.

Go to Reports > Ecommerce > Sales performance to show all the amounts refunded for each user ID.