Looking through each URL and adding meta data

Hi, I’m building a WordPress plugin that will add meta data to each page based on Piwik API data.

I’m wondering if it makes more sense to make a new API call on each page, or to call all URLs at once and then loop through each URL in the results and add the data.

The latter requires some alignment between the page entry in the database and the page in Piwik so I’m enticed to go with the former.

Maybe I’m just lazy. What are your thoughts?

I’m wondering if it makes more sense to make a new API call on each page, or to call all URLs at once and then loop through each URL in the results and add the data.

I’m not sure what you mean here?

What i’d do is call the API for each page max once, then cache it in wordpress, so you dont have to call piwik on each page. Also have a setting to reset cache in your plugin. Also have a setting to “Refresh data every N seconds” defaults to 3600s or so

You could also call the full report, and filter on each page. it’s pretty similar, whatever you prefer. However make sure it’s cached so it does not slow down the whole site.