How to get Google search query in real time? - google-analytics

Is it possible to find out in real time what query a visitor searched before landing on your site?
Google switched the URL structure to precede query (q=) with a # instead of ? or & to avoid sending data in the URL. Now document.referrer is https://www.google.com with no parameters to parse.
Before:
How does a website know the Google query I used to find it?
My goal is letting the website search its own database for related content or tools not indexed by Google.
Google Analytics has real time data. The limited beta API may enable joining a session via primary key (user_id or IP) to get their referring keyword.

Related

Google search keyword in google tag manager variable

Is it possible to pull the google search keyword that brought a person to the landing page into the GTM variable? Thinking it must be somewhere in the payload?
Google stopped sending organic search keywords some time ago, so there is nothing in the payload you can use.
This was during the general migration to encrypted (ssl) connections (not too long ago ssl/tls was used only on payment pages and the like) and IIRC Google said that removing that info from the search referrer was a security measure to prevent data leaks when moving from secure search to potentially insecure sites or something like it).
So since there is no information on organic search keywords, you cannot get it from within GTM. For ads you can add the matching keyword (i.e. the keyword that triggered the ad, not what the user actually typed) via value track parameters to you destinantion url and get it from there.

Filter OUT traffic with a specific query variable

I want to have Google analytics ignore all traffic that comes with a specific query parameter, ?mysearch=1
I am using that query parameter from an internal tool that I cannot change nor can I have the tool use a specific user agent, it's an ancient monitoring tool that I am being mandated to use.
It will always hit the site at a few different specific URLs, e.g. https://example.com/?mysearch=1 or https://example.com/about/?mysearch=1 or https://example.com/team/?mysearch=1
There will never be a time that real traffic will have the ?mysearch=1 query variable.
You can try to use a segment when you see your Analytics data that exclude all users that contains page with ?mysearch=1. So you can see report without these users.

How can you pass analytics source information between two websites using different versions of Google analytics

I have a website that uses Google Universal analytics and need to integrate to a booking engine which uses the old version (ga.js).
They want us to the the utma, utmb ... values in the query string when we redirect to the booking engine but those cookies and their values no longer exist.
Is it even possible to integrate the two versions of the analytics engine so we can pass the source information to the booking engine?
Should we downgrade and use ga.js tracking javascript?
Downgrading is not actually possible, but you might run the old code in parallel (which really seems a bit hackish).
A proper solution might to
attribute an id to each of the visits and store it in GA
pass the id as url parameter to the booking page so they can store in their analytics
send them a weekly report that includes visit id and source/medium/campaign so they can match it with their data
Of course you can store campaign tags (if any) in a cookie and pass them to the booking site, or write a custom function that emulates the way Google computes source/medium. But you cannot get source information from UA since this info is now computed on the tracking server and not stored with the client.

How to query Google Analytics using Javascript

We're want to query Google Analytics remotely, to retrieve (and display) a list of most popular pages (in a certain period) on a website. The examples I've looked at, for querying Analytics using Javascript, seem to require an user/person to login. Is this correct? Is there a way of skipping this step, and querying Analtyics unattended?
Thanks,
Toby
No. the data inside Google Analytics is potentially strategic and the tool doesn't provide non-logged in access at any time.
In order to do what you want the best approach is probably to query the data using your credentials on the server side and store the data on a database. Run that again every night or so.
Then you just query the database and generate the count to display on the frontend.
You don't want to do that on javascript because you would be exposing your credentials to anyone visiting your site to query all your Google Analytics data.

Separate analytics for each profile page within a single website

There are multiple profiles on my website and each user is managing his/her profile himself. I am trying to find the most efficient way to present analytics of each profile to its owner. Here are 3 ways I found:
Record each and every hit made on a profile page against that profile. This is not just count of hits, this requires to record IP, country, referrer, search terms etc. against each hit. This would require me to manage a huge database as there would be a lot of hits on each page. And a lots of processing on this database. Even if I have to de this, what database is recommended for such use?
Use Google Analytics on each page. But I am not sure that Google Analytics provide an API to fetch Analytics for individual pages.
Use some open source solution like piwik. Again I'm not sure if they provide per page analytics or not.
Please suggest the pros and cons of using each approach.
Update: More explanation - Think of it like a facebook page where each user can see hits on his page. What solution you'd suggest?
For Piwik, you can create a site id for each user, because you are allowed unlimited site ids with Piwik. You can can use a tracker with that user siteid, so when your member logs in, they get data only on their pages. You might also want to look at using custom variables and use the Piwik API to filter data.
Check here for info on multi-tracker: http://piwik.org/docs/javascript-tracking/#toc-multiple-piwik-trackers

Resources