Pass Google Analytics Data into iFrame (we control both the domains) - iframe

Currently we have a page laid out like this:
Page on Domain A contains an iFrame with Domain B inside it.
These are both our domains and we are using the same Google Tag Manager/Google Analytics code on both domains. How do I track traffic data into the iFrame from the parent page, so it does not display as "direct" and I can see all the correct information.
It is very important for me to be able to see the parent URL which is hosting the iFrame.
I do not think this is a duplicate question because we control both domains.
Thanks!

I would suggest adding the parent page URL to the Querystring for the embedded iFrame. So if the iFrame URL is current "http://myiframedomain.com/page1.html" it would become "http://myiframedomain.com/page1.html?embeddedIn=http%3A%2F%2Fmyparentdomain.com%2Fpagewithiframe.html"
On the pages within the iFrame you could read this data with either server side code or javascript and pass it to analytics.
In order to set the referrer manually in GA, you could use _gaq.push(['_setReferrerOverride','http://myparentdomain.com/pagewithiframe.html']);
For more on manually controlling referrers with GA, see https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking#_gat.GA_Tracker_._setReferrerOverride

Related

Tag Manager Trigger with Value of Originating Link Page

With Google Tag Manager, I want to create a tag that tracks the originating page that links to a form that is in an Iframe, why is a form in an Iframe, because I deal with netsuite, I know, horrible. Anyways, I want to be able to submit the form and pull the url or element by id from the original page where it was linked from. No cross domain as it is all within the same domain. Thank you all for any help.
Well for Form ID and Page url you will need you have predefined variable in GTM
http://take.ms/PPdTj
And for Url of the page on which the iframe exist you would have to modify the href of the iframe and append a parameter with required page url
and then extract the query param using gtm

Google Analytics: Track third-party form submission embedded in iframe (with another iframe)

I have a form hosted by a third party embedded on my site via an iframe (I'll call this the "Parent iFrame"). I would like to track those form submissions in Google Analytics. If I embed another iframe (src being a page on my site that contains my site's GA code; I'll call this the "Child iFrame") within the Parent iFrame's form submission confirmation message, when the Child iFrame loads will that be recorded as a Pageview in Google Analytics?
I researched this question and believe the answer is yes, but the answers I found were usually to more specific questions that didn't directly address this probably much more basic question. Thanks for any help!
I'm a little concerned about the iframe within an iframe situation, but I'm hoping that a visit within an iframe is simply tracked like any other page. Just didn't want to assume... :)

Correct setup for cross-domain Google Analytics

I can't imagine this is an uncommon problem, but we keep running into challenges.
We have a campaign with a landing page on our site, with a form visitors can fill out. They give us their email, we email them some content. We want to track this as a single GA conversion.
Right now the setup has three pieces:
1) The campaign landing page on our web site
2) The actual form they fill out, which is in an iframe and hosted on a subdomain (info.MMMM.com instead of www.MMMM.com) (this form is managed and hosted by marketing automation service Pardot)
3) The "Thank You" page to which users are redirected once they fill out the form. This is on the main domain, not the subdomain.
We're using Universal Analytics, I believe. We have the stock UA snippet in the overall site footer, so it already appears on both the landing page and the thank-you page.
We have a cross-domain issues, in that right now info.MMMM.com appears as a high-traffic referrer. Of course this is wrong -- that's our own subdomain, and it's masking the real referrer.
I've been following Pardot's instructions for cross-domain tracking. In doing so, I added our UA code snippet to the code generator for the iframed form. This works, but the Google Tag Assistant then tells me I have two GA tags for the same property (one in the iframe and one in the overall page footer I guess).
Am I headed up the wrong tree? Should I just be following the guidelines for "Cross domain auto linking for forms" on this Google page?
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain
Any pointers would be helpful.
Thanks,
SGL

Preventing trackPageView call in GA from GTM

We have many clients that are using Google Analytics (GA) via Google Tag Manager (GTM) on their website. My company provides AJAX pages for our client's site where we track user interaction using custom trackPageView calls. For regular GA code this was not a problem - we would set up the GA code in the static header, omitting the trackpageview call
<script type="text/javascript">
var _gaq=_gaq||[];
_gaq.push(['_setAccount','UA-5620270-1']);
</script>
and then whenever the user interacts with something on the AJAX portion of the page (initial page load, clicking options etc) we call trackPageView with a virtual URL
_gaq.push(['_trackPageview','/someurl?param1=abc&param2=def']);
The problem we have with GTM is that we are getting double tracking - the initial trackPageView call coming from GTM, then the virtual URL call on the AJAX portion of the page - on initial page loads. We can't disable the virtual URL on initial page loads on our end. We need to be able to get GTM to send through all the GA code (setAccount, domain name etc) except for the trackPageView bit. Is there any way to do this in GTM?
Not the most elegant, but easy to implement solutions:
pass a virtual url to the page call in GTM and set up a filter in your data views that excludes this url from the reports or
place your GA code in a custom tag instead of using a code template and omit the trackPageView-Call
I am not sure if this option is possible given your description, but virtual pageviews are not the best solution -- the total pageviews and related metrics are inflated and you cannot tell which segments are really engaging with the site more and which less.
Event tracking would be a smart way to do this. And with new GTM this is not difficult to setup at all. You could create all-new tracking (to the same account) and attach a string to your new tags, and then simply add include-only filter that will not allow any other requests.

Google Analytics referral triggered by a bookmarklet

I have a question regarding Google Analytics and unwanted referral stats generated by a bookmarklet.
I have a web service with GA installed. My users are using a bookmarklet to accomplish a certain task while visiting some other web page. Bookmarklet creates an iframe and opens up a page which is also on my domain and that page contains the same GA code.
For some reason GA sees those web sites (pages that bookmarklet was used on) as referral pages. That creates a problem for me since those pages are not real referrals (no actual links to my site). I have no desire to track pages my users marked with the bookmarklet.
It’s important to mention that bookmarklet page must be a part of the same domain as my main page. I can not move it on other domain or subdomain.
This is what I tried so far:
I’ve created a new GA account (subdomain.mydomain.com) and used it only on my bookmarklet page hoping that all stats related with the bookmarklet will appear on that account. This worked only partially. Stats for the bookmarklet started to appear on the new account but my original GA account continued to track referral pages.
We tried to use a pop up window to load a web page instead of the iframe. No difference.
Any help on how to get rid of unwanted referral sites would be appreciated.
See _setReferrerOveride:
_setReferrerOverride()
_setReferrerOverride(newReferrerUrl)
Sets the referrer URL used to determine campaign tracking values. Use this method to allow gadgets within an iFrame to track referrals correctly. By default, campaign tracking uses the document.referrer property to determine the referrer URL, which is passed in the utmr parameter of the GIF request. However, you can over-ride this parameter with your own value. For example, if you set the new referrer to http://www.google.com/search?hl=en&q=hats, the campaign cookie stores a new campaign with source=google, medium=organic, and keyword=hats.
_gaq.push(['_setReferrerOverride', 'URL-YOU-WANT-AS-REFERRER']);
Or, you could try
_addIgnoredRef():
_addIgnoredRef()
_addIgnoredRef(newIgnoredReferrer)
Excludes a source as a referring site. Use this option when you want to set certain referring links as direct traffic, rather than as referring sites. For example, your company might own another domain that you want to track as direct traffic so that it does not show up on the "Referring Sites" reports. Requests from excluded referrals are still counted in your overall page view count.
Async Snippet (recommended)
_gaq.push(['_addIgnoredRef', 'www.sister-site.com']);
You would have to grab the referrer and populate it dynamically. Probably with parent.document.referrer Of course this might make any referrals (non-bookmarklet) from these sites not record in the future. And, at some point you would need to clear them.
The most simple solution, if you don't need to track the hits from the bookmarklet at all, is to simply not include the GA code in the web page when it is opened by the bookmarklet.
Your bookmarklet can open the page like http://yoursite.com/?mode=bookmarklet
And in your server side code you can use something like
if ( mode != "bookmarklet" ) {
outputGaCode()
}

Resources