Google Analytics API For getting total clicks and impression on element - google-analytics

I am really new to Google Analytics and I had a requirement of tracking clicks and impressions. I followed following link
http://www.statstory.com/tracking-clicks-and-impressions-in-google-analytics/
and sucessfully implemented the same.
Now my requirement is to get the no.of clicks and no. of impressions
to my html page. I am googled for past quite hours but couldnot find
any luck with the same.
Any help would be highly appreciated.

You should really consider implementing Google Analytics Enhanced E-commerce functionality.
Google Analytics Enhanced E-commerce
In regards to answering your question of the API, you should query it asking for events. Namely category, action and label events and apply a filter to only return the data you wish to receive, such as 'Impressions' as a filter for 'Event Action'. That will return all impressions and if you instead change the filter to use 'Click', you'd get all clicks instead.
If you followed the above guide and made it into Universal, then you'd see the calls you set and it is set up in the following way:
_gaq.push(['_trackEvent', 'Banner', 'Click', 'BANNERNAME',1.00,true]);
This bit of code pushes (legacy version) Analytics data in the form of:
_gaq.push(['_trackEvent', 'Category', 'Action', 'Label',1.00,true]);
So, changing the different sections means you change how you define the data and how it will be visible in reports. Category defines the Event Category, Action defines the Event Action and Label defines the Event Label.
Take a look at the core development guide. Also, here you can see all the API calls available: Dimension & Metrics explorer for Google Analytics

I gather that you want to track impressions for banner advertising that is displayed by yourself (i.e. not through an adserver) in your website.
I agree with Mr Sponge that you should upgrade to Universal Analytics. if you want to implement enhanced e-commerce tracking (EEC) you probably want to read about Measuring internal Promotions, which is a feature specifically build for that kind of reporting.
If you just need the raw number of banner impressions and/or need a solution that's easier to implement (but less capable) you can increment a custom metric every time you banner shows up (this is basically a counter, you might want to use it together with a custom dimension that holds the banner name). Click tracking would still be done by events (with similar custom metrics and dimensions). From that data you can assemble a custom report and use a calculated metric for click through rates etc.
Not as good as EEC by a fair margin but much easier to do.

Related

Problem tracking outbound links using TagManager

Hope somebody can help me.
I'm a newby and have a website, using Google Analytics.
I now want to track outbound links from my website to a third party website.
Based on what I found on internet, I have set up tag manager, sas you can see here:
https://saskiahermans.nl/wp-content/uploads/2022/11/TagManager.docx
However, after a few days I can't find any outbound clicks back in Google Analytics, where I'm sure there have been some.
What am I doing wrong? Can anybody please help?
Ok, after debugging it in comments and looking at the actual tracking, here what is sent to GA4 on outbound clicks on the site in question:
en: "click",
ep.link_id: "",
ep.link_classes: "",
ep.link_url: <URL>,
ep.link_domain: <domain>,
ep.outbound: "true",
Well this is plenty.
Now go to your GA4 property, Admin -> Custom Definitions (under the Property) -> Make sure your eps (event parameters) are registered as custom dimensions. Like so:
You probably want to do that for the ep.outbound and ep.link_domain. Don't do it for the link_url. Url can be too high-cardinality for GA4 to handle.
After you're done with defining custom dimensions, give it time to gather data and filter into the custom dimensions (about a day) and go to your Explorer, click the + sign in Dimensions and add your custom dimensions to the list. Now just pull the dimensions and metrics you're interested in into the report and they all should be good.
If you still don't see the dimensions filled, make sure your measurement id in the tracking tid: "G-V24L72RLMM" is the same as in the Admin -> Data Streams. It's a popular mistake when people send data in a wrong analytics property.

Is it possible to create a funnel in Google Analytics, based on JavaScript events taking place on one web page?

We have a complex order form with multiple steps all taking place on one page. From a business analysis point of view we've been given a requirement to be able to visualise the progress of users through this form in Google Analytics as a funnel.
e.g.
Option on step 1 clicked
Option on step 2 clicked
Input on step 3 completed
Checkbox completed
Form submitted
I know we can add various JS events across the form to track the actions that have been taken, but I can't seem to find a way to create a funnel in GA from this. We're using GA with Google Tag Manager.
The goal is to be able to analyse where on this form users are abandoning it, and how long they are spending on the various steps.
Is this possible? My current research suggests that GA couldn't create funnels from events a few years ago, and that it doesn't seem possible still. I don't want to use the method of virtual page views that I have seen floating around, as this comes with too many other negative effects.
If you want a manageable funnel report in Google Analytics, you shouldn't be using events but virtual pageviews. Anyway, if you don't want to use the latter, Google Analytics offers the Events Flow Report (https://support.google.com/analytics/answer/2521316?hl=en&ref_topic=2521315), in which you can see how users activate the different events you have configured, even if it is not strictly what you are looking for.
The alternative is to track these events in Google Analytics and create a funnel with Google Data Studio.

Track links with Event or Query strings with Google Analytics

I am using Google Analytics and would like to see how users interact with my site, mainly what internal links they are clicking and from where.
One approach I've found is to add queries to my links like so ?ref=sidebar or ?ref=featured
Another approach is to use Event Tracking _gaq.push(['_trackEvent', 'Article', 'Click', 'Sidebar']);
I am wondering: Is there any reason to use one approach over the other? I know Event Tracking can be used to capture Javascript events, which queries cannot. But most sites I've seen also uses Event Tracking on their links, instead of simply adding a query string. Why is that?
Query Strings make different unique urls. So if you add query strings to your pages the pages report will show multiple entries for (basically) the same url depending on how people got there, e.g.:
subsite.html
subsite.html?ref=sidebar
subsite.html?ref=featured
each with it's own pageview count and other metrics.
Usually you do not want this. Event tracking is better since it does not blow up the url count (there might be be even better ways, especially if you upgrade to Universal Analytics and use custom dimensions).

Google Analytics: eCommerce tracking seperated by layout

Already have GA (Universal Analytics) and eCommerce tracking setup on my website.
Is it possible to set a parameter in the tracking data, and separate reports by this datapoint?
For my website I have multiple views/layouts: desktop and mobile
Also i have various user entry points: desktop browser, mobile browser, in-store ordering station (iPad showing desktop layout), iOS app that shows mobile layout ("iframe" type solution).
I already have this separated in my business logic, calling it "channel" - which can be "default", "insTore" or "iosapp".
Can I somehow set this parameter in GA, so I'm able to se sales per "channel"?
I've read something about dimensions and metrics in the docs, but unsure if that is what I'm looking for!
Custom dimensions and metrics are part of Universal Analytics. If you are using ga.js you will have to switch to analytics.js to use universal analytics.
If switching cost is too high, you might want to look into Custom Variables in the old product.
-- Updated Answer --
You need to use Custom dimensions in your case. Try something like:
ga('send', 'pageview', {
'dimension1': 'channel'
});
Note that you will need to also setup what the dimension is called as described in the doc i linked to above.

Google Analytics scope question

I'm studying GA and and want to know if it is possible to save any custom information. For example I have a lot of checkboxes on the page and want to know checked statistics. I mean checks count for each checkbox separately. I see it in the following way: before postback I'm getting all checks information and send it to GA :).
What do you think?
You can use the Google Analytics javascript API to send this information to google, possibly as an event. This can happen whenever you choose, such as before form submission.
You can make events to each of the checkboxes, individualize them if you want, and see the results in "event tracking" in contents.
More info about event tracking from
google analytics docs

Resources