How Google analytics can track e-commerce visitors behavior - javascript

I am sorry if my question seems to be weird but I can't find any information on the Web..
The question is simple: how Google analytics can be able to track ANY e-commerce website's data?
Websites are different and each one is coded differently so how Google Javascript tag could detect special events like transactions and adding to cart?
Note: I am not talking about simple data like visit duration or seen pages or the URL etc. I am talking about spacial information like:
Visitors commands
Visitors carts
Visitors carts amount
Etc

Basically it works like this. There is a standard piece of javascript for google analytics that is placed on ever page typically done via an include file of some sort that causes it to be included on ever page of the website.
That basically gets you all the standard analytics (visits, page views, etc).
Then if you want ecommerce tracking (like value of orders placed, products ordered, etc) you place a second javascript file on your thank you page and that piece of javascript has parameters for order value, and products on the order (qty and price). You can see more details of the many fields that can be passed about the order here: https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce
In summary: Outside of the standard analytics that it can collect with the sitewide javascript file, Google Analytics only knows what you tell it. So if you want cart or order tracking, you need to include a special javascript file for that and pass it the information you want to see in Google Analytics.

Related

Firebase for web-distinguish between visitors of different documents of a website

I have already used Firebase for my android apps in order to get some statistics and track events. Now for the first time I want to use Firebase for my website to get some simple statistics of visits and clicks. While setting up my project, Firebase generated some code to be pasted after <body> tag.
since I have multiple HTML documents in different URLs, I have to paste those codes in all my documents. Will Firebase distinguish between the visitors of each page or they will be all summed up together? I couldn't find the answer in their documentation.
I'm not sure I understand completely but if you are talking strictly about the analytics code then it will just send all of that data into the analytics account which you will then be able to filter by url and see the visitor data for a given page.

Using google spreadsheet as a database for a tumblr theme?

I am currently using tumblr as a website for my club. On tumblr there is a page, where every club member has a 'profile card' with their name, description and profile image.
I wondered if there is any way to create a google spreadsheet with the members' information and use the spreadsheet as a database, which can be accessed in the tumblr theme's HTML code.
I have been reading about Google App Scripts and JavaScript, but I just can't seem to connect those with tumblr and my idea (and actually I am not sure if tumblr is supporting it either).
So basically what I want to do in the tumblr HTML code is:
-Access a google spreadsheet
-Parse the data into a two-dimensional array
-Use array values to create new div elements
The reason, why I want to do this is because I don't want the members to login in tumblr and go through the hassle to mess with the code. They should be able to easily put their information into a spreadsheet, which is connected to the tumblr website, and every time the spreadsheet is changed, the website just needs to be refreshed and it is again up to date.
I will be thankful for any kind of help =)
I have done a similar task using Google Sheets as a database for small sets of data to be edited by non technical maintainers, and it can work quite well.
You have mentioned that you can add custom Javascript, so it should be possible in your case. Here are the general steps you would take:
Setup your sheet to be accessed via API
Pull data via the Javascript fetch API
Process and display the data on your tumblr site
This actually works quite well and allows for easy updating of what is essentially static data.
For more info on how you can open up your sheet and access it with the API check out this article or ones like it available via Google.

Google Tag Manager js widget tracking for multiple properties

We are developing a widget that is implemented on multiple customer's websites as 3rd party element. On those websites the widget is only present on some of the sites. The widget uses Google Analytics for tracking everything that is happening there.
In the next step, we want to move from Google Analytics to Google Tag Manager. Many of the host sites we are implemented on already use Google Analytics or Google Tag Manager.
The requirement is to be able to distribute tracking data through the Google Tag Manager in a certain way:
We want to see all of the tracking information in our own Google Analytics property (this is pretty easy)
We want to send SOME of the data to the Google Analytics property our customers are using so they can view it in their own tracking.
We want to make sure that the tracking data the customer receives is not inconsistent with the tracking that is already going on. In other words: We need to avoid that users are counted twice and we want to make sure that a user that has taken a certain widget action can be viewed in the customers property with the entire browsing history (effectively inject widget activities in the regular tracking)
We don't want to pollute our own tracking by receiving a lot of data from the host site into our own property.
My initial idea how to do this (not sure if it will work):
create another instance of google tag manager (namespaced)
gather all widget events in our own tag manager
create a lookup table to distribute the tracked data to different Google Analytics properties using the hostnameas filter
So can you help me figuring out if this could work especially for (3.) and (4.) and how it should be architected?
Being your GTM powered customer I'd definitely prefer your widget not to send data to my analytics but just send event pushes to dataLayer so I could configure and customize my tags firing. This would let to avoid data inconsistency in (.3) .
Using your own GTM container alongside customer's container could lead to some data pollution since both containers will use the same dataLayer in default configuration.
To keep your own data clean you can stick to default analytics.js implementation with your separate settings and only send data to your GA account.

Implementing CPA affiliate purchases in GTM enhanced ecommerce

I'm implementing Enhanced Ecommerce on our (mainly affiliate) website through GTM. We have list views and detail views etc.. so implementing impressions and clicks is easy, but for affiliate purchases there is a problem.
We have two payment models for the shops that are showing their products on our site:
Cost per Click. I can implement a small purchase on the clickout page.
Cost per Acquisition. Here is the problem: The purchases are made on a different website on a different time. Using PHP API's I get the purchases made a few times a day through a cronjob.
How can I create a purchase (preferably using PHP, using javascript is messy on a cronjob) but retain the cookie value so I can link the purchase to the clickout and channel people used to get on our site.
I thought of creating all zero purchases for each clickout and maybe repurchase using the same transaction ID. This might work, but we will end up with thousands of empty purchases.
I ran across a similar problem a while back. Our checkout lives on a different domain. So when Adwords people would checkout after migrating to Universal, I was losing that data at checkout. I think my solution there could help you. This all assumed you're using Universal Analytics and not the old deprecated libraries.
The first thing I do is grab the GA cookie, which is named _ga. Inside it is your GA session. It looks like this (it will be much longer)
GA1.2.3456.7890
The third and fourth number sets (including the period) are the session itself. Parse them out.
Now you want to find some way to store this with the user. I used my PHP session (we pass it in the query string when we jump domains) and stored it there. You'll have to figure something out that works for you here.
On the other site we need to specify the GA session and site within the GA block. Please note that the new site will report these visits as if they belonged to the original site. The UA-XXXX-Y should be from the original site and yourdomain.com should be the new site TLD
ga('create', 'UA-XXXX-Y', { 'cookieDomain': 'yourdomain.com', 'clientId': '3456.7890' });
Now you can pass your purchase metrics in. When a session converts on the new site, the old site will track it, along with any other things that session held (i.e. page impressions, Adwords clicks, etc.). You don't need any messy cron jobs to do this. Just be aware, as I said earlier, that these page visits belong to the original site as far as GA goes. You could try reporting two sets of metrics to get around this, but I have not tried that.
Reading the comment beneath the answer from Machavity, i assume that you are using Universal Analytics, or else Universal Analytics is the way to go!
I have had a case in the past where we had to think of a one way tracking system because we didn't have access to the other site's code.
Give a look at the Google Measurement protocol. This protocol makes it possible to send raw userdata directly to google analytics over HTTP.
Link to Google measurement protocol

Google Analytics not tracking clientside redirects

I'm trying to solve a problem with tracking traffic to individual blog posts on a system that uses a javascript redirect system where something somehow break tracking.
The way the system works is as follows:
Permalinks are in the format of domain.com/ab_XXXXXX where ab_XXXXXX is a unique code. That code is parsed by a piece of javascript, which tells the browser to load the individual blog post page. This page has a URL format of blog.html/?cd_XXXXXX_ef=YYYYYY. Here too, XXXXXX and YYYYYY are unique codes which, combined, identify the particular page.
When I load the blog.html/?cd_XXXXXX_ef=YYYYYY URL directly, Google Analytics does seem to track the page and the user shows up in the real-time dashboard as visiting that particular page.
However, when I load the domain.com/ab_XXXXXX URL, the user does not show up in Analytics' real time dashboard, even though the analytics tracking gif gets loaded.
Since the ab_XXXXXX URL is the permalink, Analytics appears to contain no data on individual blog post visits at all.
I'm not the programmer on this system, and at this point I'm not sure what to test or to suggest as changes to the programmers.
My question is: why would Analytics track the user in the one occasion, but not in the other? And what could be done to remedy this?
Does the page ab_XXXXXX actually redirect the user to cd_XXXXXX_ef=YYYYYY or does it simply load the contents of that blog post into the same page? In either case, but particularly the latter, you can simply choose to manually track the page view in your existing Javascript snipped by adding something along the lines of _gaq.push(['_trackPageview', 'blog.html/?cd_XXXXXX_ef=YYYYYY']);

Categories