In the Ecommerce Transactions with Google Analytics, we can code as below:
_gaq.push(['_addTrans',
'1234', // order ID
'SitePoint', // store
'19.99', // total
'1.50', // tax
'3.00', // shipping
'Chicago', // city
'Illinois', // state
'USA' // country
]);
But I want to implement it for employer registration page where I wont get order_id and total fields. Instead can I use employer_id and company name by replacing oerder_id and store...
Will it works ?
for reference you can see GA Ecommerce
How to use it for employer registration ?
You can do that but it may not be the best way to do it. If I were going to do it this way I'd use some code to generate a dummy transaction id and then set the total fields to $1. Here is some code to generate an order_id:
function generateOrderId() {
// really crude unique ID
var d = new Date();
var r = Math.floor(Math.random()*1000);
return d.valueOf()+''+r;
}
A better way to do this is to track it with events. These are designed for tracking special things that don't have a dollar amount directly associated. For example, downloads, or the number of times a person clicks play on a video player.
The docs are pretty good and if you understand that Sitepoint article the event tracking won't be hard. (it's actually a simpler process than ecommerce)
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
Related
I need to send a cart status update based on an offline activity. My customers will add items to their cart online via the website but the final checkout and purchase happen offline.
Here is my question: In the example below, a checkout step is updated. Does the client_id provided in this step have to match the original client_id used when the web user started their cart originally?
Measuring Checkout Options
v=1 // Version.
&tid=UA-XXXXX-Y // Tracking ID / Property ID.
**&cid=555 // Anonymous Client ID.**
&t=event // Event hit type
&ec=Checkout // Event Category. Required.
&ea=Option // Event Action. Required.
&pa=checkout_option // Product action (checkout_option).
&cos=2 // Checkout step.
&col=FedEx // Checkout step option.
Client ID is how Google Analytics tracks each individual user throughout their multiple sessions. So, yes- if you want that payload to be associated with the same user, then the CID will need to match- otherwise you'll be artificially inflating your user count (as well as severing the contextual data from that user).
You can parse the cookie that GA stores in the browser to obtain the CID and then fill it there. Not sure what language you're writing in, but there are plenty of snippets out there for parsing the GA cookie. You could also store the CID when it is initially generated in your own session data to be used later while offline. For example:
ga(function(tracker) {
var clientId = tracker.get('clientId');
console.log(clientId);
});
You could also provide your own CID from the start that you generate yourself and tell Google Analytics to use. This might be overkill for your situation, but I wanted to mention it as an option.
in Google Tag Manager and Google Analytics, I am trying to track cart addition so that I can then compare them with effective purchases and see which product I am losing most of my business for.
Till here, I am fine. I set up the following data layer with a product array.
for (var i=0; i < myvariable.length; i++) {
window.dataLayer = window.dataLayer || [];
window.dataLayer.push ({
'event': 'AddtoCart',
'ecommerce': {
'currencyCode': myvariable[i]['currency'],
'add': {
'products': [{
'name': myvariable[i]['name'],
'id': myvariable[i]['id'],
'category': myvariable[i]['category'],
'price': myvariable[i]['price'],
'variant': myvariable['variant'],
'dimension1': myvariable[i]['mydimension'],
'quantity': 1,
}]
}
}
});
}
Now, I need to persist data layer throughout the different ecommerce steps in order not to duplicate the values every time user goes ahead or even jump backwards. And here is the problem, based on the structure of the ecommerce I work with:
Page 1: product list
Page 2 (optional, depending on the settings): product upgrades
Page 3: Guest details
Page 4: Confirmation
In page 1 when a user selects a product he jumps directly to page 2 (if present) or 3. If he wants to select another product he has to go back and select again. All products are stored in the cart, which is generated as soon as the user adds a product, regardless of page the user is.
What I would like to have is to track all product listed in the cart before he either closes the page/jumps out of the purchase process or confirms the purchase. It doesn´t really matter what he adds, removes, re-adds during the purchase process. Basically the last cart status (with all products listed) is what I want to be sent to Google Analytics as an event.
I understand this is something I can achive with cookies, but not sure how exactly I should set it up, store all data in it and then trigger it to GA. I would really appreciate a few hints in this matter.
Thanks in advance for your help.
Here is how you can setup a cookie
How do I create and read a value from cookie?
You will setup the cookie with any value you'd like
GTM can read cookies
https://support.google.com/tagmanager/answer/6106899?hl=en#web
http://www.simoahava.com/analytics/variable-guide-google-tag-manager/#1
you would need to create a variable with 1st party cookie and enter the name of your cookie
and then add filter to your trigger to fire when variable does not matches your value
Hope this help,
Cheers Analytics ML.
I'm using the following tutorial, http://www.lunametrics.com/blog/2014/03/04/tracking-offline-transactions-universal-analytics/ which tells us how to add a transaction manually using a url like the following:
http://www.google-analytics.com/collect?v=1&tid=UA-123456789-1&cid=75839030.509493873&t=transaction&ti=52ea5aab1f0c2&tr=1100&cd1=52ea5a8bc6a4a
This works ok. However, the eCommerce part of GA does not register a conversion, so it's not possible to use the multi channel funnels report.
I'm wondering is there a way to register a sale similar to how a shopping cart would on a webpage? Would I have to add in the "clientId" for the customer, into the cart so the sale can be recorded against all the other actions in GA?
OR am I doing something wrong? Such as not registering an item? Would this trigger the ecommerce conversion to register?
Either way, somehow the ecommerce tag is not firing, so I can't record multi channel funnels based on clientId
You need save clientId in custom dimensions and in your site (it can be hide field, for example)
If you send transaction with use real clientid (send cid and cd# parameters) = this transaction will be linked with this user and all actions with this cid
On my practice better send t=event&ec=ecommerce&ea=purchase&pa=purchse&item...
With this method I have all data in ecommerce reports
Most of my website traffic come from adwords, and fill a form to get called.
When A user fill a form, I have a customer created on my database.
For my business strategy, I want to know how much I payed for that lead, and how much benefit I make with it after the call.
For that I think I have to link analytics visitors and my customers directly.
I am searching for a way to put an analytics visitor ID on the request form or something like this...
You would need to get the visitor id and pass it into either a custom variable (ga.js) or custom dimension (analytics.js).
To get the visitor id for Google Analytics (ga.js) *I got this code from How to obtain Google Analytics visitor unique id? SO Answer:
_gaq.push(function(){
var tracker = _gat._getTrackers()[0];
var visit_code = tracker._visitCode();
console.log(visit_code);
});
To get the visitor id for Universal Analytics (analytics.js) *More documentation on this in Google's documentation:
ga(function(tracker) {
var clientId = tracker.get('clientId');
});
I've used this before, too:
ga.getAll()[0].get('clientId');
The best strategy in your case is:
Get user ID from GA or UA(as desribed advisor above)
Send user ID to database
Set up user ID as custom variable(in Googl Analytics) or custom dimension(in Universal Analytics)
Set up custom reports, where you can segment your visitors by their ID's
Is it possible to pass more than one label in a single call of _trackEvent(category, action, label, value) so it could be used in report as a separate as a separate dimension or for filtering purposes?
My requirement is to track links (downloads) clicks for documents related with many meta-data parameters (document ID, product ID, category, language, revision etc.) and all those parameters should be available in customized reports.
Thanks in advance for help.
GA is not set up to track that granular of data about any one item.
And, since GA uses gif requests to send the data, you may bump up on the limit given the amount of data you want to send.
One way of tracking all the data you want to would be to push the data into a database via an ajax request.
If you have to use GA for this, you may be able to send multiple _trackEvents for each or a grouping of the meta-data items based on the document. A setTimeout should be used so GA has time to send the events. See Can I track multiple Google Analytics events at once?
In your case you would use:
function recordOutboundLink(link, category, action) {
_gaq.push(['_trackEvent', 'Click', 'Download', 'Whatever']); //could be mutlipush here
setTimeout('document.location = "' + link.href + '"', 100);
}
HTML
<a href="http://www.example.com/pdf.pdf" onClick="recordOutboundLink(this, 'Outbound Links', 'example.com');return false;">
Also, install Chrome and the Google Analytics Debugger. Look in the console (control, shift, j) for the event tracking processing.
If you don't see all of your events tracking there (they will be listed separately), then something is up maybe with the tracking code.
I've found in API docs that the same goal (tracking multiple key-value pairs sent in one _trackEvent request) could be achieved with custom variables:
_gaq.push(['_setCustomVar', 1, 'Items Removed', 'Yes'],
['_trackEvent', 'Shopping', 'Item Removal']);
The one important limitation of this approach is up to 5 maximum number of custom variables (or up to 50 extended custom variables for Premium GA Account)