Google analytics in iframe content (different domain) - iframe

I have been reading some google documentation on tracking via google analytics, but still hasn't have a clear understanding of what's happening, I will put this in plain english so that my query can help others as well.
Basically I have 2 sites: siteA.com (parent), and siteB.com (child)
I have created a widget on siteB.com, i.e. siteB.com/widget. Let's say in this case I embed siteB.com/widget on siteA.com (home page)
<iframe src="http://siteB.com/widget"></iframe>
And on siteB.com, I have the relevant google analytics installed. So my question is:
Will siteB.com google analytics be able to register siteA traffic? (one traffic to siteA.com equals to siteB.com/widget.)
Many thanks!

Short Answer : No, It is not as simple
For cross browser tracking:
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite?csw=1#trackingIFrames
In a site where the transfer between domains is done by opening a new
window or by including content in an iFrame, you will need to to
use the _getLinkerUrl() method to transfer visitor and campaign
cookies from one domain to another. For example, suppose you include a
form in an iFrame that is hosted on www.my-example-iframecontent.com.
In order to transfer visitor information from the parent page that
hosts the iFrame on www.example-parent.com, you would use JavaScript
to load the iFrame and pass in the cookie information using the
_getLinkerURL() method.
There are different ways to setup and it all depends on your configuration. Therefore, I suggest that you setup some test profile and experiment with your settings.

Related

Tracking UTM paramaters in iframe with own Google Analytics

I'm having issues with tracking the UTM parameters in Google Analytics on an iframe.
My website is embedded in an iframe on http://www.blokker.be/inuwkot and http://www.blokker.be/danstonkot. The visitors go straight to the two links (either dutch or french). No visitors go straight to my own domain.
In the overview page form analytics I can view the amount of visitors/views but not the UTM parameters. I can only see it's a referal.
Any ideas on how to get the UTM url's working in the iframe so I can see where my visitors come from?
Since your frame content is located on a different domain you can not track url parameters from the hosting page without support from the domain owners - they would either have to append the parameters to the frame url, or send a message using the postMessage interface which allows cross-domain communication between pages and embedded frames.
So the page has to send the information to the frame, you cannot simply access it (for security reasons). If the owners of the blokker.be domain do not support that then you are out of luck.

Google Analytics : How to track image/PDF URL is accessed?

I am sending an marketing Email attaching an image or PDF URL.
Is there is any way to track how may users viewed/clicked this page via google analytics ? I could see the number of page view who accessed html pages but seeking for a way to find how many of them accessed image or PDF URL?
Including a link directly to a pdf or image will simply open the resource without JavaScript tracking or cookies required for Google Analytics.
You would need to send a GA hit from your server in response to the request for those files - neither trivial nor recommended in this case
Rather send the link to a page on your site containing the content.
Tracking that in GA is trivial and is likely already set up on your site.
If you need to have the content in a PDF rather than on the web page directly, have a link to the PDF and track that as an event or Virtual Page View
I would also recommend tagging the link in your email with GA UTM Campaign Parameters to identify the traffic from that link
If your question is about tracking the email itself, please restate the question.

Can I use Google Tag Manager to collect analytics from mulitple domains?

The set-up:
1 site, 2 domains: = mysite.com and mysite.co.uk
These 2 domains use DNS to point to the same site (IP).
There is 1 snippet of Google Tag Manager (GTM) code just after the opening <body> tag of the site (every page).
In the GTM container, I have added both domains on the "Container Settings" page.
There is one Google Analytics (GA) account which only contains the .co.uk domain. (An analytics account can only contain 1 domain.)
A tag has been set up in GTM with the type of Google Analytics and it has the UA code from the 1 GA account added.
A rule has been added to fire on all pages
Now, I don't care whether someone visits via .com or .co.uk, but I want to capture combined analytics for both. My questions is, with the way I've set things up using GTM, will GA save data for both domains ie mysite.com and mysite.co.uk, or do I need to set things up another way to achieve this? Ideally, I don't want to go down the forwarding route i.e. forward all traffic from .com to .co.uk.
First a bit of pedantry: Google Tag Manager cannot even collect informatiom from a single domain (it's not a tracking tool). And while you can only enter one domain in Google Analytics that domain setting serves no actual purpose; a Google Analytics account can track multiple domains in different "properties" (porperties are sections in an account that each have a unique id) or in a single property via cross domain tracking. Cross Domain tracking is used if you want to treat multiple domains as a single presence on the web (i.e. if you have a website and a shop with different domains, they still belong together).
Now, the way you have set things up data will be collected from both domains. There are at least two caveats:
1) If users can switch between domains inside a session (go from .com to .co.uk and back) their sessions will be interrupted and Google Analytics will register multiple visitors (that's because users are tracked via cookies which are domain specific). To avoid that you'd need to set up cross domain tracking (and how you would do that depends on if you are using Universal Analytics or asynchronous code. Look at your tracking code, if it contains a line that starts "ga("send"...." your are using analytics. If it contains lines that start with _gaq.push you use asynchronous code).
Cross domain tracking documentation for UNiversal Analytics (analytics.js)
Cross domain tracking for asynchronous code (ga.js)
2) By default Google Analytics tracks only the path, not the domain. If pages on both domains have the same path they will be displayed in aggregated form in the reports, that is if you have an index.php on both pages the visits for both will be added up. Maybe that's just fine with you, if they show the same content in any case. Else you'd either have to use "hostname" as a second dimension (which is not a sticky setting, you would need to re-apply that every time you switch to another report), or you create a filter on your view that includes the hostname in the reports.
Those caveats are relevant because data will show up in any case and will look perfectly okay even if it's not (even if you decide that those two things do not bother you you need to take them into account when you interpret the data).

how can I know where users come from if they are coming from another website of mine?

I have two websites, website A and website B, the website A is a hotsite that is linked to website B, where the sales happen.
We need to know how the user got the website A and turned into a customer in website B(it means he bought something), so we can mesure the good sources to invest.
as the developer, I have access to these two websites source-code and can implement any google-analytic tag on them.
Thanks,
Jonathan
Web browsers generally send a referrer header, which contains the URL of the page which linked to the current page.
You can access this in the HTTP requests made to site B, and track sessions differently when the first page load is referred by site A. You can also access a document.referrer property in JavaScript, and use it to manipulate your analytics.
The correct way to implement this in Google Analytics is to configure the trackers so that they work cross-domain.
This will allow you to see all the information about where the converting visits originally came from and their path to purchase.
If you don’t use cross-domain tracking or you have it improperly configured, you’ll end up with meaningless data that shows self-referrers in the visit reports and a lack of proper attribution towards your conversion points.  As a visitor moves from your primary domain to the other, they will start a brand new session in Google Analytics.
...
If a visitor clicks an ad or performs and organic search and ends up viewing a page on the www.3rdpartycheckout.com after viewing pages on www.primarydomain.com, you lose ALL data about how that user arrived and the complete picture of what they did.  If they end up converting, you will only know that they came from www.primarydomain.com (which is not helpful at all).
http://www.blastam.com/blog/index.php/2011/02/google-analytics-cross-domain-tracking/
Have the landing page on website B look at the referrer tag and if its website A then use a separate Google Analytics instance on website B for all sessions that were sourced from website A.

Does anyone use Google Analytics? How Google does it to avoid counting the owner of the website as visitor?

I don't want to be counted as visitor every time I test my page in the hosting. Does Google know i'm the owner of the site by checking if i'm logged in my Gmail account?
I don't think Google does anything like this automatically. But they do provide instructions for excluding based on IP address (or range) and apparently also now by cookie. If you use a CMS or admin interface, you could put the code they provide in an HTML file that you then include into the admin interface pages by IFRAME (to ensure that the cookie stays set for anyone who uses that interface).
One option is to install Ghostery addon your browser. Ghostery can block trackers and scripts used on webpages likes google analytics, google adword and other adwares.
You can also block or unblock the trackers for a specific site or specific tracker for a particular site.This add on is available for Firefox and chrome browsers. If you have this installed on your browser, your visit wont be counted as google analytic script wont be executed.
You can learn more about ghostery at: http://www.ghostery.com/about
There are also often application specific ways of blocking google from counting administrators. For example I've used a wordpress analytics plugin that would automatically not include the tracking code if the user was logged in as an administrator. If you are application has the concept as admin then you could write something similar that controls when the code is added.
If you visit your site frequently from connections with a dynamic IP address, eg. home broadband, then excluding IP addresses is not particularly practical. To go beyond IP exclusion, you can create an isolated page on your site that only you know about that includes a call to Analytics to label your cookie.
The Google Analytics _setVar() function lets you label yourself with an arbitrary string, eg. 'internal'. You only need to do this once per browser as long you don't clear your cookies.
Having labelled yourself as 'internal', you can create an Advanced Segment within Google Analytics to exclude visitors with that label.
Google Analytics relay on you embedding a call to their JavaScript see this link - do not confuse it with how Google does page ranking.
So the answer to your question is that your pages should be smart enough to recognize when the request comes from you and skip the call to the JavaScript.

Resources