简体   繁体   中英

What is the best way to import Google Analytics data into a MySQL database?

Does anyone know how to best import Google Analytics data into a mySQL database (or any other SQL database)? I am asking about both the method of importing the data as well as how to best store it. I do not believe Google Analytics offers any information about what their data schema is. Is there a best practice for what the table structure should be?

I was able to find some information about how to import the data on this thread: how to push GA data to mysql tables . I do have the tool Analytics Canvas which facilitates the process of making API calls and exporting the data, however I do not know how to best organize the data into different tables.

Thanks for the help.

I don't think GA offers an API for this purpose but I am pretty sure you can build one yourself. For example, if you are using PHP, the global variable $_SERVER provides you with everything you need to build a service that simulates what google does with GA. If you are using Wordpress you may be able to find nice plugins to get information about your visitors. Now looking twice to what you want, if you have a spreadsheet, export the data to a csv file and create a PHP script that will read the file line by line and import it to a SQL table. You may need to create such table(s) and their relationship for this to work. Let me know if you need further assistance.

I built a powershell script to query the GA Core Reporting API and save the data to a csv file, from which our warehouse software can ingest it.

See my github for the tutorial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM