Utilities for sending offline ecommerce measurements to Google Analytics. This might be useful if you want to tie offline transactions to website traffic tracked by Google Analytics.
Right now there is one script send-measurements.py
that sends offline ecommerce transactions from a CSV file to Google Analytics via the
Google Measurement Protocol.
pip install pyenv
pyenv install python 3.6.5
pip install pipenv
pipenv shell
You'll also need a Google Analytics ID for your web property, it will look something like UA-XXXXXXXX-Y
where X and Y are decimal digits. Get it from your Google Analytics console under Settings.
./send-transactions.py --google-analytics-id <GOOGLE_ANALYTICS_ID> --input-file transactions.csv
See the file transactions.csv
file format, it should have a header row and the following fields:
client_id,transaction_id,product_name,product_price,product_quantity,transaction_amount
client_id
should probably be the user's Google Analytics ID and is usually a UUID.
Note that you will need to use the Google Analytics Real Time pages to see these transactions as you send them. They won't appear in your regular Google Analytics numbers for 24 hours.
This uses the great google-measurement-protocol library.
I hope you find this useful.
cheers
adam
Adam Feuer
Seattle, WA, USA