google analytics event tracking for individual users - google-analytics

Hi am using google analytics ga.js to track a button click event. It is working fine. However, i want to track the button click event for individual users in my site.(eg. karthik - 5, Richard - 7 etc ) Am using wordpress. How to achieve this?

There are ways track non PII user data using Google Analytics. This is an example of importing CRM user data, which you could use import the type of information you are looking for.
Basically you can send in a User Scoped Custom Dimensions which represents a user with the hit data,and then import a CSV to map that dimension to any other user scoped custom dimension.

I have find a solution for this. I have used event tracking to achieve this. I have used the following function in the click event of the button.
_gaq.push(['_trackEvent','button-category','Click','Clicked by the user:User id from my site ']);
In the label field i use the logged in user id from my site. Now, i can see the clicks of a particular user using his id under Behavior->Events->Pages->Your Page->Event Category->Event Action->Event Label. As username is personally identifiable info according to google, i didn't use username.

Related

Track login event with google analytics 4

There's already a question similar to mine, but it doesn't tackle my problem.
I'm trying to set the google tag manager to track login events in my website.
But I can't identify the action related to the login event on the tag assistant.
Here is a print of the actions when I login:
None seem to be strictly related to the login event.
I tried to track some of these actions, but they occur in many other actions.
(thus, I collect data I don't need, as if they were login events)
What of these actions is related to the login event?
How can I precisely identify the login action ?
You can automatically implement data layer events on form submissions with ListenLayer.com. In this case, you will likely need to use their Custom Forms Listener.
You have to create an account, place their script on your website, enable the Custom Forms listener and it's features and then identify your forms under the Listener's event settings. You would do this by writing a simple rule to match the CSS class, ID, or form Name element etc. (these things would exist in the <form> tag.
Here you can see I have set some rules to identify a form like this
<form class="form-container"> or <form class="listenlayer">
Publish and test on your website.
Now, when the form is submitted, the Listener will automatically push data into the data layer identifying the form and the action.
From there you would use GTM to register and read the data layer activity. I assume you know how to do that since you have the GTM debug view going, but basically you'll get a new message on the left side with an event name and you can create a Custom Event trigger in GTM and also register Data Layer Variables to use in your trigger. It's all down hill from there!
With tracking you are usually left out with two approaches :
Either you ask your developer to implement a dataLayer event on a specific action / interaction so that you can then use this as a "custom event" trigger in GTM. For instance, here, on the login success page, after the GTM snippet, the developer could invoke the following code:
dataLayer.push({ event: 'login' })
That will allow you to use 'login' as your event name in GTM custom event trigger.
As you began doing, if your developer cannot implement it, you may try to identify variables that will help you isolate that specific action / page. For instance here, maybe does your successful login page has a specific URL you could use in a page view event, targeting that specific page path.

Track user-id in button click - google analytics

I would like to track a button click event on my wordpress site. But i want the info in such a way that how many clicks were made by a particular user. Can i pass user-id from my website and get the number of clicks for the user-ids?
I'd split this out into two areas: (1) tracking the button click, and (2) collecting data by user. For tracking the button click, I would recommend Event Tracking. For collecting data by user, I would recommend passing in a non personally identifiable user ID as a user-scoped custom dimension. Then, you'll be able to create a flat table custom report with your custom dimension and event category as dimensions, and total events as a metric. Then you can see events per user.
One additional note here, you might want to explore using the User ID feature, which allows you to measure logged in users across browsers and devices. But even if you use the User ID feature, you'll still need to use custom dimensions to see data by User ID.
I have find a solution for this. I have used event tracking to achieve this. I have used the following function in the click event of the button.
_gaq.push(['_trackEvent','button-category','Click','Clicked by the user:User id from my site']);
In the label field i pass the user id from my site. Now, i can see the clicks of a particular user using his id under Behavior->Events->Pages->Your Page->Event Category->Event Action->Event Label. As username is personally identifiable info according to google, i didn't use username.

Track a login event in Google Analytics

I would like to track a login event on my website.
The user writes username and pass then clicks on login, the form is submited and server checks if password is correct then redirect to the home page if it is.
But how could I add a Login event to GA? If I add it to the login button it wont be totally accurate as it will count even the failed login attempts.
Any ideas on how to solve this?
Thanks
Chris
Great question!
I think what you want is the Custom Variables that google analytics offers.
Simply put, for each page your user visits you set a custom variable with it's username for example.
I don't think you are interested in the login event, rather you are interested in what a logged in user visits - and this solution solves your problem
The Custom Variables answer will serve your purposes as outlined below but if you want another alternative (or actually really want to use Track Events) you could also add in a parameter to a successful logon which you can then read and process as you wish.
So for example:
Login
This will create a link to your login page. If the login is successful it will redirect back to the current page with the parameter login=true in the URL.
(You could check this parameter via JS for example and fire the Analytics track event call based on this).
One way to do this is let your login redirect to a page which says something like: "Thank you for logging in" and register this pageview to Google Analytics. And then have that page auto redirect you after 5 seconds to the page you were viewing. I've seen this done on a good amount of websites. If your login is using partial refresh you could even do it without having the user pass by a seperate page.
The simplest way is to use virtual pageviews (tutorial). It's a small piece of JS code, that you execute on any event you want. It makes GA think that there was a pageview. So you make a conditional statement like "if login == OK -> create a virtual pageview with URI "virtual/login/OK". Then you simply set this URI as a goal.
Custom Vars can be used for individual users but you need to set up a unique ID so that only you could recognise that once you pull the data out of GA. So in your dbase set a GoogleAnalyticsID against each user, then send that as a custom var to track users.

Using Google Analytics, if I explicitly log an event using _trackPageview, does that count as a 'real' page view?

For example, if I have a news page that's already being tracked via GA and I add a javascript event to capture clicks on a specific link to the news page (e.g. navigation) am I then 'double counting'?
If a fake pageview is not beneficial in this situation, and from your description that you're looking to track an engagement click on your page, use Event Tracking instead of Pageviews.
Tracking a click/event is easy (especially if you're already using Javascript). The best part is that this event is not considered a page view, keeping those stats safe.
The implementation is simple and allows for quite a bit of customization:
_trackEvent(category, action, opt_label, opt_value)
Below is an example of a link that's been encoded with an event tag:
Play
Here's the Google Analytics resource page on Event Tagging:
http://code.google.com/apis/analytics/docs/tracking/eventTrackerGuide.html
Well it's not a real page view, but Google Analytics thinks that it is--i.e., it shows up in your pageview counts.
Fortunately, it's easy to filter those so they don't contaminate your pageview data.
So for instance,
_gaq.push(['_trackPageview', 'unique_virtual_pagename']);
So in your GA Browser, you'll see the number of clicks actually shown as the number of pageviews of *unique_virtual_pagename*, which is not good.
There are a two ways to fix this (that i am aware of): (i) set a temporary filter at the bottom of the pageview table; or (ii) set a persistent (c*ustom*) filter in your Admin Panel (which i think is best) to remove pageviews having only the name *unique_virtual_pagename*, or whatever name you've chosen. This will of course take up to 24 hours to set, so the best plan is to set the filter first, then add the javascript to your page. so the filter is active when you begin collecting clicks.
But that just solves the problem of disaggregating these virtual pageviews from your real pageviews, you still need a way to count/record them.
I prefer to create a separate profile in these cases. So first, i filter the virtual pageviews from my actual pageviews using a custom filter, then i create a new profile which has another filter excluding everything but these virtual pageviews. I usually give that profile a name based on the event.
What you're doing is registering what's called a 'virtual page view'. To GA it's seen as a real page view and shows up in your content report's and page view counts etc. This is often useful if you want to show a page view for media that GA can't track. It's also commonly used to count an event, such as a button click, as a goal conversion.
If you just want to record the event and not count a page view you should look at using GA event tracking instead.

Use Google Analytics to track Google Form submissions

I'm using Google Forms (a Google Doc spreadsheet with an automatically generated form that the user can fill in to submit their details) and would like to track the submission of the form as a virtual pageview in Google Analytics so that I can measure conversions. Does anybody know if this is possible?
While Crayon Violent is correct about the built-in capabilities, there is a viable option: If you're able to host the Google Form HTML on one of your own pages, you can treat it like any other form (you can literally copy and paste the form HTML from the form page). As long as you leave the inputs unmodified, and the form action remains as its presented, it will post successfully to the form, regardless of where it is hosted from. (You can remove the styling elements if you wish.)
You can see a sample of that here: http://jsfiddle.net/PVBqX/2/
And you can see the data record just fine in the Google Spreadsheet here.
And, if you use Firebug or Webkit inspector, you'll see that the virtual pageview is sent:
There is an alternative solution to track pageview in Google Analytics using an image impression inside the Google Doc which I have been using it in my spreadsheet.
Check out the following link for the guide of explanation on how this works:
Tracking-google-sheet-views-with-google-analytics
For example, using little Apps Script will include the sheet key and locale in the image url (to include this you your own project open you Sheet and then Tools > Script editor and paste the code in):
function getGABeacon(tid){
var id = SpreadsheetApp.getActiveSpreadsheet().getId();
var locale = SpreadsheetApp.getActiveSpreadsheet().getSpreadsheetLocale();
return 'https://ga-beacon.appspot.com/'+tid+'/sheets/'+id+'/'+locale;
}
Then in the Sheet we can then use the cell formula like =image(getGABeacon("UA-48225260-1"))
EDIT
You can also build a tracked URL and pass it to the beacon on targetted page using this function
var trackURL = SpreadsheetApp.getActiveSpreadsheet().getUrl();
Probably you should just use Url shortner tool like https://goo.gl/ or https://bitly.com/ to get analytics on how many clicks are made and little bit of analytics like locations, browsers etc through them.
You can add Google Analytics in general by setting up a new page which includes the form using an iFrame and then adding the Google Analytics tracking code right before it.
I found a service that does exactly that and is completely free. It's called GFormAnalytics. It will generate a new link for you and then you share that new link and it will track your forms with your own Google Analytics tracking code.
Check it out here: https://GFormAnalytics.com
Here is what I did using Zapier (free basic plan), no coding needed:
How to use Zapier to trigger a goal conversion in Google Analytics (used with Google Tag Manager) when an embedded Google Form is completed
In Google Tag Manager click on Triggers to create a new trigger.
For trigger type, select "custom event."
Set it to trigger on "Some Custom Events."
Set the trigger to fire when the Page URL contains a unique part of a URL e.g. "/pages/contact."
Name (e.g. "Contact Form Submitted" and save the trigger.
Click on "Tags," then click "New" to create a new tag.
For tag type select "Universal Analytics."
For Track type select "Event."
Under "Event Tracking Parameters" for "Category" enter "Form Submission."
For "Action" enter "Submitted."
For "Label" enter "Contact Form."
Leave "Value" blank.
Under "Non-Interaction Hit" select {{Event}}
Under "Google Analytics Settings" select {{Google Analytics}}
As the trigger for this tag select the trigger you just created, "Contact Form Submitted" (or whatever you named it in step 5) which should show as a custom event.
Name the tag (e.g. "Contact Form Submission") and save.
Press "Submit" in the upper right corner to activate the new tag.
In Google Analytics, select the gear icon in the bottom left (Admin settings).
Under "View" select "Goals."
Select "Create New Goal."
Select the "Submission" goal template in step 1.
In step 2, under "Type," select "Event."
In step 3, for "Category," "Action," "Label" enter exactly the same thing you did in Tag Manager in steps 9-11 (case sensitive).
Leave "Value" blank.
Save the goal.
In Zapier, select "Make a Zap!"
For the Trigger App, select "Google Forms."
Select "New Response in Spreadsheet."
Connect your Google Forms account.
Choose the spreadsheet connected to your form.
Under "Worksheet" choose the "Form responses" that shows up in the drop down menu.
Select "Google Analytics" as your action app.
Select "Create a Measurement."
Connect your Analytics account.
Select your Account and Property.
Under "Type," select "Event."
For "Category," "Action," "Label" enter exactly the same thing you did in Tag Manager in steps 9-11 (case sensitive).
Leave the other fields blank.
Test and activate the zap.
Go to your website and fill out the form.
After at least 15 minutes (enough time for Zapier to have checked the spreadsheet linked to your form) check your goal conversions in Google Analytics to verify that the zap is working.
If you Edit the Form and select Responses menu, then select enter Tracking ID, paste in your tracking ID in and you will get page views as he goes to each page including the confirmation page which has Page Title of "Thanks!". This works even putting the link to the form in an email. Works great, tracking the mail open, then the pages and submit of the form, but I haven't figured out how to pass the user ID so both types of events carry the same user ID.
not possible. You have to be able to add code to the actual file being served.
Only thing I can think of is if it lets you redirect to one of your own pages after form submission, put the code on a page you create on your own site

Resources