Reputation: 34338
I have a blog with the Google Analytics tag in the various pages. I also have links on my site pointing to pages on my site as well as external pages. I have not set up custom events or anything like that.
For a given url/page on my site, within a certain date range, I want to programatically get (ideally from the GA API):
Search words/traffic sources that unique users/traffic from outside my website (e.g. organic traffic searching on Google) used to land on and view that page
For specific links on that page - both internal and external - I want to know the number of unique users who clicked on the link and the number of clicks
For specific links on that page - both internal and external - I want to know the search terms/sources of the users/clicks of the links vs. the visitors that didn't click on the links
Is there a way I can fire a given link on my blog into the Google Analytics API to get this data? I already have a 2-column table that has all of the pages on my site (column 1) and all of the links/urls on those pages (column 2).
I am using Python for all of this btw.
Thanks in advance for any help!
Upvotes: 0
Views: 267
Reputation: 13334
Regarding the information you're looking for:
(not provided)
(here is some info and workarounds). You can get this data in the GA UI by linking the search console, but that data won't be exposed via the GA API, only the Search Console API (formerly "webmasters"), which unfortunately you won't be able to link with your GA data.ga:eventAction
or ga:eventLabel
to filter on your links (depending on how you implemented the events), and ga:totalEvents
/ ga:uniqueEvents
to get the total / unique number of clicks.As for the GA API implementation, before coding I advise you to get familiar with the API using:
Once you get the results you're looking for, you can automate with the Google Python Client (it's the same client for (nearly) all Google APIs), GA being a service you use with the client, and you'll find some python samples here.
Upvotes: 1