Better way to run heavy scripts using WordPress database

  1. How many posts do you have? – Maybe there are some delays because of hosting?

  2. You want to create your own plugin collecting the data from Google Analytics – I’m not sure you’re able to do that.

  3. “The main idea is to get views per post and store them with post meta.” –
    Why do you want to collect that in post meta?
    If you want to collect this data – I recommend you to create your own tables in the database.

There is a lot of ready PHP scripts which you can use for creating your custom plugin on WP. It’s the fastest way I guess.

A sample of my custom plugin for collecting stats (from the whole website).

enter image description here