Hi am using the following code to track the clicks of the users using custom variable. But in my custom variables report the count is getting increased for user log in but not for button click event. Am storing logged in user id in a variable and passing in the custom variable method as the value.
jQuery(document).ready(function(){
jQuery('#buybutton').on('click', function() {
_gaq.push( ['_setCustomVar', 2, 'gaid', <?php echo(json_encode($userName));?>, 1 ] );
_gaq.push(['_trackEvent','button-webtrader','Click','webtrader-buttonclickevent']);
});
});
I have find a solution for this. Instead of custom variables, 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:<?php echo(json_encode($userName));?> ']);
"$userName" above contains 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
Is it possible, (via Appscript), for one Google Form "Form A" to create and open another Google Form "Form B" during the onSubmit trigger of Form A?
I want to ask a user how many entries they want to make on Form A. Then I want Form A to effectively "call" Form B for each entry desired.
I can create the form dynamically or FormApp.openByUrl() but they both fail with an error. I'm beginning to wonder if a Form cannot be subordinate to a Form?
Any experience with this?
You can create a copy of your form with the onSubmit trigger of your source Google form.
function createGoogleForm() {
const sourceFormId = "xxyy";
const file = DriveApp.getFileById(sourceFormId);
return file.getUrl();
}
I want to get the usage data of my customer out of google analytics, to make some usability analysis with it. For this, I need something that I can determine, which event was done by which user. Is there a possibility in a google analytics api to get this two parts linked?
You could add a user ID as a custom dimension, you'd probably want to set the scope to user.
https://support.google.com/analytics/answer/2709828?hl=en
This would allow you to connect up which users performed which actions.
Of course you can! :) I have used it in a lot of projects.
https://developers.google.com/analytics/devguides/collection/analyticsjs/sending-hits
Example:
ga('send', {
hitType: 'event',
eventCategory: 'Video',
eventAction: 'play',
eventLabel: 'cats.mp4'
});
Since clientId has been made available through the API as ga:clientId you can use this value.
I would recommend using a custom User Id though - setting you own generated User Id in the script using the Universal Analytics User ID feature and in your backend db.
Also add the id to any link you send to your clients via email/sms/etc. that lands on your homepage to follow up on marketing performance.
You would need to have some javascript that grab the id and set it on the pageview. (like Linker, but adjusted for user id)
Note to anyone using the Universal Analytics User ID feature The values returned in ga:clientId is actually the userId Even more interessting. (As of time of writing) GA fails if you request clientId from a User ID view. So you should use a non-User ID view to get the User ID. :)
I want to add a Custom Variables called Custom Variables to my website.And I defined a datalayer on Google Tag Manager.I also add the code snippet on the page which I want to get the Custom Variable.
<script type="text/javascript">
var external_id = jQuery('#edit-external-id').attr("value");
dataLayer = [{
'externalID': external_id
}];
</script>
I debuged the configuration of GTM.Here's the picture
I got the message.But I can't see the value statics on my Google Analytics.I think the menu path of GA is Audience-Custom-Custom Variable.Am I right?Anyone can help me?
Writing values to the dataLayer does not make them appear in Google Analytics; it just makes them available in GTM.
You need to set up a Google Analytics Tag - there is a tag template for Universal Analytics where you can insert the Google Account id. Use the default "all pages" trigger. Since you are receiving data I assume you already have done this.
Now in GTM go to the "variables" menu, click "new" and select "Data Layer Variable" as type. Enter the key from the dataLayer that you want to be evaluated, i.e. "externalID". Give your variable a name, I suggest to simply use the dataLayer key. Save. Now you can use the variable by calling it via its name surrounded by {{curly brackets}}.
Go back to your GA tag. I assume you want to save the value as custom dimension, since custom variables are deprecated in the current GA version. You need to create a custom dimension in Admin/Property/Custom Definitions/Custom Dimensions. When you create a custom dimension you will get a numeric index to address the dimension by. Go to your GA tag, advanced configuration, custom dimensions and click "add". Enter the numeric index and after that select the variable you want to send.
Custom variables do not show up by default in the standard reports; you can either selected them as "secondary dimension" from the dropdown above the data table, or create a custom report.
First, you must never, ever use dataLayer = [{...}] after the container snippet (preferably don't use it ever). You're overwriting the container snippet by reinitializing it as a new Array. As you can see, in your Preview panel there is no "Page View" event (should be just before DOM Ready), which means e.g. the All Pages Trigger won't work.
Second, "Custom Variables" are deprecated. They've been replaced with Custom Dimensions in Universal Analytics.
Third, did you actually add this variable/dimension to a GA Tag?
Here's how it should work:
1) In your script replace dataLayer = [{...}] with:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event' : 'variablePushed',
'externalID' : external_id
});
This is the safe way to interact with dataLayer.
2) In GA Admin / Property Settings / Custom Definitions / Custom Dimensions, create a new Custom Dimension with the appropriate scope, and make note of the assigned Index number. If you are unfamiliar with Custom Dimensions, you have some reading to do. Start with https://support.google.com/analytics/answer/2709828?hl=en
3) Create a new Custom Event Trigger for Event Name variablePushed, name it e.g. "Event - variablePushed" (without quotes).
4) Create a new Data Layer Variable for Variable Name externalID, name it e.g. {{externalID}} (without curly braces).
5) Create a new Event Tag, with Event Category: External ID, Event Action: {{externalID}}, and set the Non-Interaction field to True.
6) Browse to More Settings -> Custom Dimensions in the Event Tag, and add a new Custom Dimension. Set the Index number from (2) and set the value to {{externalID}}.
7) Add the Trigger you created in (3) to this Event Tag.
What happens now is that when the externalID dataLayer.push() takes place, the Event Tag fires a non-interaction event to GA (so it won't affect Bounce Rate), which piggybacks the Custom Dimension with it.
I'd like to track how many people hit my website that might be logged into LinkedIn. Depending on the results, I might add an interactive LinkedIn section using their API.
I already have the Javascript logic to detect if they're logged in. My question is what is the best approach to log this result? Can Google Analytics do it with a custom variable or event detection?
I'd love to report on something like, "10,000 visits to my website, of which X number of visitors were logged into LinkedIn".
Any help would be appreciated!
I believe Google Analytics Custom Tracking Variables would do the trick. Something along the lines of:
_gaq.push(['_setCustomVar',
1, // variable slot
'LinkedInUser', // variable
'true', // value
1 // variable scope, 1=visitor
]);
_gaq.push(['_trackPageview']);
For custom variables (not that is this is a user-triggered event after the initial GA page load logic, a call to _trackPageview is needed to push the data back to GA), or:
_gaq.push(['_trackEvent',
'PageView',
'LinkedIn'
]);
For custom events. Just pop something similar to that into your JS routine that checks for authed LinkedIn users.
our marketing consultant has asked me to help with configuring google analytics to setup Goal Tracking for User Signups... from what I've read this is accomplished by assigning the URL of the page the user is directed to after a successful signup to the Goal you are trying to track.
but what if the URL your user is directed to is a URL they regularly visit? e.g. after signing up they are directed to their profile page - which is the same page they visit every time they login. is there some way to configure a referer to go with the goal URL so that it is the pair of them that define the goal? e.g. user visits /profile and is referred by /signup.
further complication: what if after signup the user is directed to a different page depending on the user type? it would be nice to configure a single Goal with multiple URLs (but still using the referer restriction described above).
an alternative would be to use an event... if the server creates a user then it could signal the view to output the javascript code that generates the appropriate event.
or... is there a way for server-side code to send events to google analytics? is there an api?
If your users are directed to is a URL they regularly visit you can make a conditional statement for the goal occasion with a virtual pageview, have a look at this: http://services.google.com/analytics/breeze/en/et_vps/index.html
If after signup the user is directed to a different page depending on the user type, you can use regular expressions to set goal URL pattern, like this ^user./login./(type1|type2|type3)/$, look here for more info: http://services.google.com/analytics/breeze/en/regex_ga/index.html
I came across this question in google and believe I found a more appropriate answer.
Google Analytics now provide a service called Analytics Measurement Protocol.
This will allow you to send server-side requests to track your users activities in your analytics account.
To track a sign up event as mentioned in the question, the best way I can see would be to first create an event based goal in your account with the category set to 'users' and an action as 'sign_up' (you can optionally provide a label and value). Then in your code once a successful sign-up occurs (maybe when a user confirms their activation email link?), send a POST request to www.google-analytics.com/collect with the following payload:
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
&cid=555 // Anonymous Client ID.
&t=event // Event hit type
&ec=user // Event Category. Required.
&ea=sign_up // Event Action. Required.
&el=label // Event label.
&ev=1 // Event value.
A full list of the parameters and their meanings are defined here: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
You could use an event that is triggered when the user submits the sign-up form :
onsubmit="_gaq.push(['_trackEvent', 'Category','Action','Label','Value']);"
and use the Category / Action / Label data model in Google Analytics to pass whatever data you need to pass, for example :
onsubmit="_gaq.push(['_trackEvent', 'Sign-up','Premium','6-month',6]);"
You then have to configure this Goal in Google Analytics as an Event, which lets you choose which combination of each of the fields Category / Action / Label / Value you want to use.
Another option, maybe less maintenance-heavy, is to use a query-string to identify people that get back to the Profile page after having just signed up. So instead of sending them back to /user/profile after they sign up, you send them back to /user/profile/?sign-up=true.
You will then be able to track these pages as a URL goal in GA using a Regular expression like :
\?sign-up=true
I wrote a helper function for tracking GA events.
function trackGoogleAnalyticsEvent(category, action, label) {
try {
ga('send', 'event', category, action, label);
} catch (e) {
console.warn('Google analytics error: ' + e);
}
}
Usage:
trackGoogleAnalyticsEvent('Signup', 'Signup Success', 'Facebook');