views:

1202

answers:

2

our partners sites leverages our iframes in their own websites. I was wondering if there is a way to track the analytics on the iframes.

The problem is, if we also utilize these iframes on our own website, how do i avoid duplicate tracking where a visit is counted on our domain's analytics and also counted again in iframes? is there a way to get around it?

+1  A: 

Adding the Google Analytics code to the iframe should work just fine. The easiest way to avoid duplicate tracking is probably to add a query parameter like ?partner=foo to the URLs that your partners use. You can check for your own site's value and not run the Google Analytics code at all, and also pass the partner ID to Google so that you can break down the reports by partner.

EDIT
Use ?utm_source=foo as the partner parameter, and Google Analytics will pick it up without you doing anything. Filter out your own impressions with

if ( location.href.indexOf("utm_source=mysite") < 0 )
{
    // Google Analytics code here
}

or you can set up a filter on your Google Analytics profile to filter them out.

stevemegson
A: 

You can also add utm_nooverride=1 to your iframe source tag. This will make sure that the page that called your iframe on the 3rd party site will not get credit for the referral, but rather the initial source (AdWords campaign, search query, etc.).

Example:

<iframe src="mypage.html?utm_nooverride=1" width="1" height="1"></iframe>
Avishai