Inheriting the Parent Cookie in an iFrame - javascript

We use a product at my company that allows us to embed secure forms on non-secure sites to transfer information. We do this through embedding an iFrame.
We use Google Tag Manager for most of our clients, and we have a module for tracking submissions of these forms. However, because of it being in an iFrame, every time we submit a form, the source of the traffic is a referral from the parent website, the one loading the frame, not the source of the traffic, throwing our analytics off.
More information:
We're using cookieDomain set to auto on all pageviews and events
GTM is installed on both the page loaded in the iFrame, and the page loading the iframe.
Pageviews are currently set to track on All Pages except for the domain the iFrame is on, but I've tried setting it to All Pages and it still tracks form submissions as a referral.
Tl;dr Form is in an iFrame. I land on a page with this iFrame from Facebook. When I submit the form, the source is the page with the iFrame, not Facebook. I want the source to be Facebook. How can I pass the cookie from the parent page to the iFrame, where the event occurs, within GTM?

Related

How to check if url-redirection occured

My tool can display external websites in an iFrame.
Few sites (e.g. "http://ec.asm.org/") are loading in my iFrame but after few seconds reloads on the same browser's tab but not as iFrame.
I suspects that it happens because the destination websites changing their location (redirection) to the same url during the page load (onLoad).
Is there way to verify this assumption (redirection to the same page)?
Is there any other possible reason for this problem (iFrame closed)?

Tracking interactions of a Single page Application in an Iframe

I have an iframe which contains a single page application, And I am looking to record actions within the form and hits to the page because it’s a single page app, do we need to add event tags to trigger the GA recording, as currently the page does not change URLs as you move through the form.
For Example “example.com” content is served in an “iframe” from a sub-domain (account.example.com/tba) that is a Single Page Application.How can I track interactions from it
Also help me with the GTM implementation

Submit form in an iframe to a cross domain page

I wrote a chrome extension which injects a toolbar on top of sites (say amazon.com) as an iframe at the top.
When the user click on the action button on the toolbar (inside iframe), it's basically a form submit action, with action pointing to my full site (on another domain).
It's working, however only inside the iframe. I'd like the whole page to redirect to my site, rather than the iframe.
Is there anyway to do that in extension?
If you are using an iframe :
Same Origin Policy prevents you from doing this.
Unless you can hack/XSS the other site's files to inject the JS, you will have a hard time.
Now if you legitimately need to communicate with the other page, and you either have control of the other page or can setup it to communicate with your server, you can use window.postMessage, JSONP or even Ajax with CORS (latter 2 will be harder to pass dynamic content though). But I believe it is not the case.
else :
you can directly inject the js script in to the page itself by that you can handle all operations in the main page same as running something on chrome console.

How can I remove an iframe within an iframe on an external web page like Pinterest's bookmarklet?

I am in the process of making a bookmarklet that allows users to highlight text on an external web page.
It runs JavaScript code that appends a JavaScript file from my server to the current web page that takes the title of the current web page, the URL of the current web page, and then the highlight text of the current web page. Finally, the user would click a button to submit the data to my web server to be saved into the database.
I have two ways of doing this: (1) have a popup with the data in the URL as parameters, or (2) to have an iframe inserted into the current web page with a form to submit the data.
In the one with the popup (1), the users browser auto blocks the popup for every domain. How do I get around this? It seems like Facebook share and twitter tweet buttons bypass the popup blocker though...
In the one with the iframe (2), I want to remove the iframe from the DOM after submitting data. However, if I'm on another domain, I get an error saying I am denied access because of origin policy something. I know it's possible because Pinterest's bookmarklet does this, it inserts an iframe then removes it from the current DOM.
I am looking for information on how these solutions work, so I can do something similar with my bookmarklet.
I resolved this by adding a post message callback after saving the data from the iframe.

Retrieve URL from iframe using window.postMessage

I'm trying to access the URL of an iFrame that I open on my site. The iFrame is from another domain so traditional methods violate the same origin policy and are flagged as cross site scripting. However, I just discovered window.postMessage, but I don't quite know how to pull it all together.
My goal is to capture the final URL in the iFrame. For example, a user clicks a button on my site to open an iFrame. Say that iFrame loads a web site and the user clicks around on the site. When they close the iFrame, I want to capture the URL so the next time they click the button on my site, I can open the iFrame to the same state that the site was in last time they visited. Is this possible with window.postMessage?
Thanks!
document.iframe[name].src
document.iframe[name].document.location.href

Categories

Resources