Say we've produced a widget for other sites to use, like so:

<iframe src="http://example.com/whatever.php" frameBorder="0" width="200px" height="300px"  scrolling="no"></iframe>

The client would like to be able to see within GA who has embedded the thing. Is there some referer information automatically passed that I can look for, or do I need to add something?

whatever.php is already loading the analytics Javascript(we're also tracking clicks on an outbound link).

Looking around a bit more, I found what seems to be a similar question on SO with an answer saying this can be found, automatically, but I still can't seem to find the information. The question's also old enough the respondent is probably referring to the old interface, though. Maybe someone could explain getting to it in the new look. (I won't likely be able to train this client to switch, deal with the old look, etc.)

4 Answers 4


If you have not modified the tracking snippet, this traffic will typically end up on your client's Traffic Sources > Referrals report - unless the widget is embedded in a document served over SSL or the user-agent is configured not to send the referrer header. (change the embed code to src="//example.com/whatever.php" if possible)

This may be acceptable (particularly if you have set up a separate profile for tracking the widget) but you can get more reliable results if you use Javascript from within the embedding document to pass the actual referrer to your widget.

Embed Code

<iframe frameBorder="0" width="200" height="300" scrolling="no" onload="this.src='//example.com/whatever.php?ref='+encodeURIComponent(window.location);"></iframe>

Widget Document

<!-- ga.js snippet -->
<script type="text/javascript">

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXX-X']);
    if (
        array_key_exists('ref', $_GET) &&
    _gaq.push(['_setReferrerOverride', '<?php echo $_GET['ref']; ?>' );

    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

<!-- eof ga.js snippet -->

Note: This method could use some polish - the iframe call isn't semantically valid HTML (though example in question was not either).


Do you do server log file analysis, if so the simplest (hacky) way would be to track the requests for image content within the widget.

I had quick google and this thread seems pertinent to your problem


I would add a single pixel image into the HTML that that iframe is using. Check your raw access logs for each time the image has been accessed and extract the unique domains / IP's from the logs. You may be able to use the image tracking feature on getclicky.com over the javascript to have the stats in their application / interface


You might be able to use GA's _trackPageview, and grab the domain of the referrer via javascript(something like j=document.referrer, _trackPageview(j)) maybe.

Haven't tried that myself, but have used custom _trackPageview('Page Descriptors') before.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.