google analytics tracking in iframe feeding to different partners - iframe

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?

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.

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>

Related

Adding additional information for referral links in Google Analytics

I've been trying to do a bit of research into this but am not really able to find a proper answer.
I have a number of ad campaigns for my site and I want to see where referrals are coming from and which ad campaigns are working best.
For example, I want to tell how direct email marketing campaigns are performing compared to one another. Normally I think most of these come up as 'direct' traffic in Analytics.
However, I want to know if there is some way I can change the URL's in the various ad campaigns like:
example.com?adcampaign=1
example.com?adcampaign=2
example.com?adcampaign=3
etc,
And then be able to see these in Google Analytics as referrals like Google, Facebook etc,.
Note:
I am using Google Tag Manager to handle advanced ecommerce tracking in Analytics
For future reference this is what is needed:
utm_source // the source it came from
utm_medium // the medium used
utm_campaign //the advertising campaign it is part of
ref: support.google.com/analytics/answer/1033863?hl=en

Only tracking code in index page?

I'm using Google Analytics for the first time. I have been waching some videos about how to set up Google Analytics for a website. I'm a little bit confused. In the videos they paste the tracking code only once like in the index.php. Is this really enough? Can Google Analytics track all the activities on all other pages in my website? I thought there should be a unique tracking code for each page on the website or am I thinking wrong here!? Preciate some explanation. Thanks!
Basicaly it is enough. You have to put google analytics code to all pages you want to track. You can do it by putting it into for example index.php which is shared by each page. Google analytics will handle all the activities on all pages and you will see results in admin section (reports and other staff).

How to make an analytics for my website members page?

I have a website where members can create their own page. Current I have a script that tracks how many views the member page was viewed. But I would like to display more information like unique visits, return visits etc.
Is there any analytic software that could let me do that?
I am guessing you want to display on each member page some analytics information.
You didn't specify what language you used to build the site.
Here's a PHP API class to query a Google Analytics account.
Also, check this and this for documentation about the API. You can retrieve analytics data / metrics in many ways that the default Analytics reports don't show.
Now you need to think of a way to differentiate between member pages in Analytics (use custom variables in your tracking code, maybe).
Hope this helps.
If you don't want to deal with getting in to the Google Analytics API, I suggest you check out some of the solutions on the Google Analytics Application Gallery. I for one work with embeddedanalytics. While we don't have it very well published on our site, we have done a number of CMS type implementations, allowing a single implementation to be used by many different users of the site. The differentiation could be based on page path or some specific custom variable. Visit us and contact us directly if you are interested.
(disclosure - I work with embeddedanalytics)

Custom Google Campaign Tracking

I'm building out a site that has predefined affiliate ids that are driving traffic to our sites. We currently use this paramater to track our seo work internally. Now we want to do the same through Google's Campaign Tracking at the Session level. The problem is we don't want to change our url, is it possible to manually build the Google campaign tracking pixel url? I'd like to take our affiliate ids and convert them over to a tracking campaign pixel for Google.
Seems like Google built this so all the tracking data must be in the url, is there a way to do the same tracking w/o the google data in the url?
Instead of:
http://www.mypage.com/?utm_source=google&utm_medium=cost-per-click
I want to use(javascript will do the rest):
http://www.mypage.com/?affid=123456
Turns out here is exactly what I was looking for:
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking
This is essentially doing everything the Google Campaign Tracking does but you have full control over what parameters are passed in the tracking pixel. I don't have to change or mess with the url, our in house tracking will work as it should, and now the google tracking pixel will be built as I specified.
You can programmatically set up a virtual pageview based on the affiliate id.
In an if statement, determine if you have an affiliate id. If you do, write some logic to build out the proper campaign, medium and source, then concatenate it to your URL. Pass that to GA via the trackPageview method instead of letting it do it's own thing.
Keep in mind that passing a virtual URL does replace it's default behavior, so you won't have the affid parameter in your content reports unless you build it in to the virtual pageview.

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

Resources