List of URLs and visits from Google Analytics API - php

I want to show number of visits of each article on my page. I am trying to download a list of urls and visits from Google Analytics using PHP class. I was searching for some sample code but no luck. I need result with all single urls and visits of these urls. I found only samples where people were getting total visits or visit of single url. I need a list of urls and visits.

Are you using the google-api-php-client. It has a class "\Google_AnalyticsService" to perform analytics api calls. You can get your pagePaths by setting the "dimensions" of your query.

Related

Get keyword that my site searched for

I am working on a website where I want to get keyword that my website was searched for on Google.
For example my website is for architect services, someone goes on Google and searches for "Architectural drawings" and gets my site in search and clicks.
I want to get that keyword stored as variable to serve dynamic content.
EDIT
Looking at the answers I think i did not make myself clear.
I am signed up with analytics and I get reports on what keywords by site is being searched for.
What is currently want is When user clicks on google search result to visit my page, i want to use the keyword in order to deliver dynamic content on my page. so if user searched for "Architectural Drafting" and click on my link on search result, i want to deliver content related to architectural drafting and if keyword id "Architectural Design" then content may differ, so i need to get keyword stored as variable when visitor is on my page.
Is that possible?
EDIT 2
I got answer that this is not possible but somehow i came along a plugin that claims under "What The Visitor Wants to Learn From Your Website SPECIFICALLY" first point "by the keywords people are using to land on your website" check link [1]. if they can personalize on the keyword people used to land on my website, there must be some technique used if not cookies, i want to find that out.
[1] http://smartduu.com/content-personalization-plugin/
Regards
Manoj Soni
You need to sign up Google Search Console to see what keyword searches on Google.
Track your site's search performance with Google Search Console and
browse around for more webmaster resources.
Optionally you can sign up Google Analytics and links it up to Google Search Console so that you can access more advance data for keyword search.
If you associate a Google Analytics property with a site in your
Search Console account, you’ll be able to see Search Console data in
your Google Analytics reports. You’ll also be able to access Google
Analytics reports directly from the Links to your site, and Sitelinks
pages in Search Console.
No, that is not possible, at least not for organic search. The keyword is not included in the request that redirects a user from the search results to your page.
If you use Google Adwords then you can ad value track parameters with the search term dynamically filled in to your destination urls. This will work for paid traffic only.
Google Analytics will not help here (for the most part it does not include organic search keywords, either).
Google Search Console will give you info on organic search terms, but not in realtime and will not help for your use case.

Tracking individual visitors in Wordpress and Google Analytics

Here is what I'd like to achieve: I have a landing page and a list of contacts. I want to send each of my contacts the link and be able to see the analytics (duration, visitor flow, conversion) for each individual. Most importantly, I just want to confirm they visit the link.
What I'm thinking of doing is using a Wordpress URL parameter to add a unique identifier to the page for each contact, and then track those pages in Google Analytics.
What is the best practice? Is there a better/faster/easier way to do track individual visitors in Wordpress and Google Analytics?
You should be building your own url for each user. I would build a url first with this link, then write a script or something to create a unique url for each user in your contacts list.
https://support.google.com/analytics/answer/1033867?hl=en
Hope that helps!
EDIT: You can also try just adding ?contact_id=99999, visit the link and then go to Google Analytics, look at the live view, and see if your parameter shows up.
Whats Happening Now: http://analytics.blogspot.com/2011/09/whats-happening-on-your-site-right-now.html
Parameters do show up in GA because on most shopping carts each page, product etc have url parameters that are unique, and can be viewed from GA. If it didn't most website applications would not be compatible with GA.

How do I retrieve a list of the pages visited on a particular day using the Google Analytics API?

We use Google Analytics on our site to track page views, and I am interested in getting a list of which pages were viewed on a given day. I'm not looking for the number of times a page was viewed primarily, as I know that this information is available if we need it. Rather I want a list of all of the unique URLs visited on the site for a given day. Is there a way to do this?
TL;DR
You can query the landing page dimension and visitor metric to get that data. For more info here is Google Analtyics query explorer and dimensions/metrics reference
Slightly longer answer:
Here is the dimension you would want to use.
ga:landingPagePath
Here is the metric you would want to use.
ga:visitors
This will give a report of the urls for the date range you want and the amount of traffic it got. If you don't care about the actual traffic you can just remove that once the data is pulled.
Here is more info/examples about google's data api's for python
If you are familiar with using the API, selecting these two dimenions:
Page
Date
and any of the relevant page-level metrics (pageviews, unique pageviews, etc.) will product the desired report.
Try using this link to shared-report from GA Query Explorer, I believe those are the numbers you want.

Twitter API Rate Limit for Multiple Users

I am writing a PHP-based application using the Twitter API. Up until now I've been using the REST API via a GET request on a PHP page. However, as my app scales, I can easily see it going over the 150 requests-per-hour limit. Here's why:
I have categories of topics, each which periodically poll the Twitter API for tweets around a topic. For example, I have: mysite.com/cars, mysite.com/trucks, etc. A user can go to either page. When he is on the page, live, refreshing updates are pulled from Twitter by making an AJAX call to a PHP page I've set up. The PHP page determines which category the user is coming from (cars, trucks), polls Twitter for search results, then returns the JSON to the category page. This sounds confusing, but there are a number of unrelated reasons I need to have the intermediate PHP page.
The problem is that since the PHP page is making the requests, it will eat up the rate limit very quickly (imagine if there were 20 categories instead of just cars and trucks). I can't make a single call with multiple parameters because it would combine multiple categories of tweets and I'd have no way to separate them. I can cache results, but if I did, the more categories I add, the longer each would have to go between API calls.
So how can I approach this problem? I looked at the streaming API, but it's only for oAuth'd users and I don't want my users to have to log in to anything. Can I use the stream on the PHP page and then just make continuous requests each time the category page polls the PHP page? Thanks for any help!
a) You don't have to use your websites user's oAuth credentials in streaming API - just your's:
get them somewhere in dev.twitter.com and hardcode them. Your users won't know there is any oAuth going on backstage.
b) Don't use anonymous requests (150 per IP per hour) use oAuth requests (350 per oAuth per hour). You don't have to ask your users to sing in - just sign in few (1 is sufficient for start) your private twitter accounts. If you don't like creating twitter login functionality, you can get credentials for your twitter account to your twitter application in dev.twitter.com .
c) As #Cheeso mentioned - cache! Don't let every pageload make twitter request.

How to get pageviews data for a separate page in GoogleAnalytics API

I am using GoogleAnalytics API library on my Codeigniter site, but i didn't find there and on Google API guide -
how to get results for a one exact page.
Say i've got page http://www.example.com/company/82808, and i make request to GA API and get pageviews and visitors metrics for this URL - example.com/company/8280.
Is this possible?
Yes, it's possible. Apply a filter for ga:pagePath
Include in the request:
Dimension: ga:pagePath
Metrics: ga:pageviews,ga:visitors
Filter: filter=ga:pagePath==/company/82808 use this exact match if that is how the page is recorded in GA. If it's recorded like /company/82808/index.php then you can use filter=ga:pagePath==/company/82808/index.php or ga:pagePath=~/company/82808 for a contains match.
Test out queries in Google's Data Feed Query Explorer

Categories