Is it possible to change the page content from a child iframe without postMessage? - iframe

I read several subjects on this, but I'm still confused. So, I'm asking:
Website a.com has:
<iframe src="https://b.com"></iframe>
Can b.com change the a.com content without using the postMessage browser feature ?
All I want is to allow b.com to make changes on a.com. How can I allow it ? Both are my domains!
I reapeat. I don't want to use postMessage.

Related

how to track clicks on outbound links on AMP container

I'm trying to create a tag that tracks clicks to external links from some of my pages. In the past I have never had problems in creating them on web container but now I have to create them for amp container and I am having many problems. Is it possible to get help?
You can use data-vars to get variable in GTAG-Manager via AMP like:
<a data-vars-youvarname="linkurl" href="linkurl>
and in GTAG-manager you can use the custom var {yourvarname}

How can I keep my referrer consistent when tracking a subdomain page in a Iframe.

I'm not sure how I should describe my situation and if I'm fully understand it.
Suppose we have a visitor flow that looks like the following:
User arrives, after a google search, at : example.com / referrer is google.com
Clicks to log in: sub.example.com/login.aspx (iframe page) / referrer is example.com
I’ve set the CookieDomain to auto and added example.com to the referral exclusion list. So from what I understand I have the following situation :
the Client ID stay consistant when I'm moving from step 1 to step 2. good !
However I'm concerned with the referrer. I would like to keep my google.com referrer when I'm moving from step one to step two.
How can I do this ?
I think you have two options here. Easy solution is to just look at your traffic sources in Acquisition reports in GA :
https://support.google.com/analytics/answer/1033173?hl=en
If you setup CookieDomain and refferal exlusion list correctly "traffic sources" will give you information you need.
Second option(if you really need to override the reffer) is to:
pass the "refferer" value from your parent page into your iframe. There are several ways how to do it but that's up to you.(e.g. query string or postMessage to iframe)
in your iframe pick this value up and send it to your dataLayer (in example below I name it {{yourValue}} )
then in your GTM you can set "reffer" field in your GA Tag for example:
Let me know if you need more detialed description on how to do it.

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

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

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()
}

Different default documents for two subdomains that go against the same site IIS 7

We have two subdomains for the same site, we would like that depending on the visited subdomain the initial page varies. But in IIS the default document setting is based on the web.config so...
We know that we could use the http:/subdomain/page.aspx but its a requirement that we use only http:/subdomain in the links
Desired example:
Click in link http:/subdomain1.web.com --> http:/subdomain1.web.com/page1.aspx
(our_website/page1.aspx)
Click in link http:/subdomain2.web.com --> http:/subdomain2.web.com/page2.aspx
(our_website/page2.aspx)
Just use the same default document and write a redirect in Page_Load based on which domain is requested.

Resources