• Resolved piet00

    (@piet00)


    hi I’m looking for a way to extract google search console data (like impressions, clicks and visitors) to use this for other purposes. Is it possible to create a sort of api endpoint which generates a json?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author tropicalista

    (@tropicalista)

    Yes it’s possible.

    I’m planning to add an export feature. Do you need to export json or do you need an endpoint to extract data by yourself?

    Thread Starter piet00

    (@piet00)

    Yes an endpoint url which contains the data in json format so I’m able to extract it myself.

    You’re a life saver if you could create something like that. I’m looking for ages for such functionality. Let me know if I can test or anything else. That would be great. Thanks!

    • This reply was modified 6 months ago by piet00.
    Plugin Author tropicalista

    (@tropicalista)

    But do you want this to be consumed inside wordpress or should be externally available? Can you contact me on my site for further explanation?

    Thanks

    Thread Starter piet00

    (@piet00)

    External available because I want to scrape/extract the data with another solution, outside WordPress.

    For instance I do the same with Plausible, website analytics, they created an API which I use and looks like this (as an example):

    https://plausible.mydomain.com/api/v1/stats/aggregate?site_id=mysite.nl&period=day&metrics=visitors,visits,pageviews,views_per_visit,bounce_rate

    but it doesn’t have to be extensive with filters and such. Data of the current day, week or month is good enough, but I don’t know which data you have/store from search console at this point.

    Yes if you prefer that: is https://www.francescopepe.com the website?

    Plugin Author tropicalista

    (@tropicalista)

    Yes the website is francescopepe.com.

    This plugin does not store any data from Search Console. It fetch it in real time.

    Plugin Author tropicalista

    (@tropicalista)

    I’ve created a sample repo to get what you’re looking for.

    Please be aware that you need to be autenticated to access this data from outside WP.

    Here’s the repo: https://github.com/Tropicalista/search-console-addon

    Thread Starter piet00

    (@piet00)

    exactly what I was looking for, many thanks!

    I responded to your email about a dimentions question

    Plugin Author tropicalista

    (@tropicalista)

    Please check the updated code at: https://github.com/Tropicalista/search-console-addon

    Thread Starter piet00

    (@piet00)

    Hi! I’m testing the new update but it results in an error. Am I doing something wrong? see what I’m trying to do: https://ibb.co/PYYhsBH

    it keeps saying “startDate field is required.”

    What I’m trying to do is this: https://developers.google.com/webmaster-tools/v1/how-tos/search_analytics#top-10-pages,-sorted-by-click-count,-descending

    but that fails on the same reason. also when I try to use “[‘page’] as dimention.

    Do you know what the correct way is use this dimention?

    Plugin Author tropicalista

    (@tropicalista)

    You must pass the startDate and endDate in payload, not in the url. I’ve changed the code to be more in sync with the API.

    fetch('https://localhost:10005/wp-json/searchconsole/v1/json_data?site=MYSITE', {
    	method: 'POST', 
    	headers: { 
    		'Authorization': 'Basic ' + btoa('YOURUSER:XXXX XXXX XXXX XXXX XXXX')
    	},
    	body: JSON.stringify({
    		startDate: '2024-05-01',
    		endDate: '2024-05-21',
    		dimensions: ['page'],
    		type: 'web',
    		rowLimit: 10
    	})
      })
    .then(response => response.json())
    .then(json => console.log(json));
    • This reply was modified 5 months, 3 weeks ago by tropicalista.
    Thread Starter piet00

    (@piet00)

    Ah ofcourse, it works now as expected. Thanks!

    One last thing, the only account in WordPress that is able to execute commands is the admin account.

    I’ve tested with a new account and different permissions, all fails.

    Is there a way to grant another account permissions to only execute/use your plugin/addon?

Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.