Impossible to track visits/referral from an iframe - javascript

We have created a website that sales online ferry tickets.
We also created an affiliate system and propose our booking engine to third party websites (via an iframe).
Ex: http://travelq.ru/s-krita-na-santorini-na-parome/.
Iframe url: https://www.ferriesingreece.com/affiliate_engine_small.php
Every time a user is searching from this engine (in iframe), there is a form submission to https://www.ferriesingreece.com/redirecting.php?aff=affiliate_name.
Problem:
We can not track visits (as referrals or as new visits) from third party websites.
Analytics do not count the clicks that comes from the iframe.
We thought it was an issue of the submitting form. So, we added a direct link to https://www.ferriesingreece.com in the iframe to test it and the result is the same. Nothing is counted.
Finally we think that this is logically happening because the iframe content belongs to https://www.ferriesingreece.com, and analytics record that the user is already in our site, so it shows up as a user is navigating in our site. (not a new visit, not a referral.)
Is there any way to track those visits/referals from an iframe?
Is there a way to add analytics code somehow in this iframe and be able to record only the clicks and the parent website as referal?

You should be able to use UTM URL parameters for this. For example, if you add the parameters utm_source=form&utm_medium=referral&utm_campaign=affiliate to your form's target, the visit should* show up in your analytics report as a referral from the source 'form'. It will also show up the 'campaigns' section of your report.
Read more about UTM here: https://support.google.com/analytics/answer/1033867?hl=en
The full target link to your form would look like this: https://www.ferriesingreece.com/redirecting.php?aff=affiliate_name&utm_source=form&utm_medium=referral&utm_campaign=affiliate

Related

Google Analytics propagate source

I am using Google tag Manager and Google Analytics.
I have a link on my yelp page like example.com/?utm_source=Yelp.
What I want is to be able to track that source even if the user clicks on a different link on my website, say to example.com/new-article.
So if a user fills out a form on that page, I know the user came from Yelp.
Summary:
A customer goes from Yelp to example.com then clicks another link. How can I still know that the user came from Yelp?
One strategy is I can append utm_source=$_GET['utm_source'] on all links on my page, but I assume google analytics or google tag manager has already solved that problem. I'm having trouble finding information on this.
Source is a session-level dimension, so if a user comes to your site with a utm_source param in the URL, that source dimension will be applied to all hits (pageviews, events, etc.) in the session.
In other words, you don't need to do anything special to make this work.

Is it possible to get url of child iframe with PHP after user navigates?

We are building an educational tool whereby students opens a website in another tab/window and then searches around the other site. Once finding the information they enter the url of the page they were on into a box. Its a bit clunky and what we want to do is allow them to open the new site (bbc.co.uk for example) within an iframe that has a header at the top allowing htem to return to their workbook.
When they navigate around the BBC site, we would like for them to be able to click a button on our frame which grabs what url they are on and some other info like page header etc and insert that automatically into their workbook.
However I cant seem to find how to grab the url of the page being viewed within the iframe. As we send them to bbc, I can get the source id easily enough but as soon as they start moving around the bbc site doing their research there is no way for the parent iframe (on our domain) to see what page they are on?
I know this is not possible in JS due to XSS issues, but was wondering if there is a workaround. Or any other way to grab the url. Currently our way of doing things is clunky, we want to make the tool a lot more easier.
Thanks
Paul

Is there a better way to track a redirect page with google analytics?

We are putting out a press release that contains links to our website and to other websites.
Right now I have a redirect.php on my website that is redirecting the user based off the variable located in the URL (e.g. redirect.php?id=1) using a meta refresh. Google analytics is loaded on the redirect.php so I can capture that visit and see where visitors are coming from before we redirect them to their final destination (either an internal page or an external page).
I do not like having to wait for google analytics to load before the user can be redirected.
Is there a better solution for this?
Here's how I would to it...
Take a look at How to Track Downloads & Outbound Links in Google Analytics
You have two kinds of links you want to track:
Links to other sites.
Links to your own site.
The how-to above will explain setting up clicks on offsite links as google analytics events (this is a better way to treat this activity than as page views).
You can then use the same basic methodology to track the clicks to your own site from within the press releases. You'll just need to find a way to select them in jQuery. Maybe by the id of the div contains your press releases, maybe you'll need to add a special class to the links you want to track. It would depend on how your page is set up.

How to Track Clicks in an IFrame with Google Analytics?

I'd like to track outbound clicks within an iframe on my self-hosted Wordpress site. I already use Google Analytics to track inbound visitors (GA code in the header), but I'd like to know which/how many of those visitors click on links within the iframe on each of my pages. For the record, the iframe does come from an external advertiser.
This is the iframe code I was given (using sample names in place of real ones):
<iframe src="http://www.advertisersite123.com//widget.html?width=510&height=950&product=2" frameborder="0" scrolling="no" width="510" height="950"></iframe>
This line of code is currently pasted on single.php, making a table of links appear on every single post at the bottom of the page.
I'd like to know how many clicks (just clicks in general is fine, don't need to know where they go) are occurring in this iframe. Ideally broken down by each individual URL on my website so I can determine which URLs are more successful in generating clicks within the iframe.
And if possible, I'd like to create a funnel that tells me which visitors to my website (by source) exit via clicks in the iframe.
Is any of this possible? And if so, what code do I add to the page?
Thank you for any and all assistance, it is appreciated!
What you are asking for is not easily done. In general, you cannot have javascript on the parent page that can hook into events on the iframed page if it is not hosted on the same domain. Same thing for the iframe page trying to tap into the parent page's DOM. This is called cross-site scripting (XSS), which goes against the same domain origin policy.
At a minimum, the easiest thing to do would be to put the GA code on the iframed page. But that's probably not something you can do (though it couldn't hurt to ask the vendor).
But some vendors (usually social media vendors such as Facebook, Google and Twitter) will have their widgets that output an iframe w/ info. They will set their server to allow for cross-domain scripting, which would allow you to tap into the iframe's DOM. Usually though they provide an API along with the widget that makes it easier to hook into relevant events (like share events), so that you don't have to do (much) coding yourself.
Basically long story short, there's no way for you to track it without the person in charge of the iframe domain getting involved.
I was searching for something similar and came across this. This jQuery Plugin lets you track an Iframe.
Tried events?
If the click is out of iframe:
_gaq.push(['_trackEvent', eventCategory, eventAtion, eventLabel]);
If the click is inside the iframe you should use:
window.parent._gaq.push(['_trackEvent', eventCategory, eventAtion, eventLabel]);

How to capture JavaScript events on a Facebook page's iframe tabs

I am planning to create some dynamic content in a Facebook tab for my fan page. It should have content displayed if the visitor is not a fan, and then upon them clicking the Like button, changing the content to display hidden carrots (metaphorically). Is it possible to capture the event of the click on the Like button from inside the iframe?
On a Facebook fan page, when the user clicks the Like button, the whole page gets reloaded and Facebook sends an HTTP post to your website with a parameter called signed_request that you would need to decode and look at with server code, not javascript. The code to decode it will obviously vary depending on what language you are using, but the process is documented on Facebooks site. Once decoded, you will need to look at the page.liked value.

Categories