Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7867719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:46:52+00:00 2026-06-03T00:46:52+00:00

I have a site that uses google analytics and is that uses a number

  • 0

I have a site that uses google analytics and is that uses a number of domains. I was asked to add cross domain tracking by doing this:

1) Add an async tracker

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21602333-1']);
_gaq.push(['_setDomainName', 'domain.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);

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

2) Add the following code to all links that go to one of the other domains.

 <a href="http://www.domain-aanvraag.nl[rest van de link]" onclick="_gaq.push(['_link', 'http://www.domain.com']); return false;">Go!</a>) 

The _link option does the following according to google:

This method works in conjunction with the _setDomainName() and
_setAllowLinker() methods to enable cross-domain user tracking. The _link() method passes the GATC cookies from this site to another via URL parameters (HTTP GET). It also changes the document.location and
redirects the user to the new URL.

Ok. This all works fine for normal outgoing links.

Here’s the problem. I have a form in which the user can select one of two radio buttons and after selecting one he hits a submit button. If the first radio button is selected a fancybox popup is opened with an iframe in it pointing to the a page on another domain. If the second radio button is opened the current window is redirected to another page on this domain.

I only want to do the _gaq_push(['_link', ...]) thingy when the user selects the first option and clicks the button.

So I have two issues with this:

  1. Where should I place the onclick.
  2. How do I use this code using fancybox? It seems to always set the document.location of the main screen and not of the iframe in my fancybox, resulting in a complete refresh of my screen.

Here’s a stripped down working example of my code so far: https://www.domain.com/test/analytics.html

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:46:55+00:00Added an answer on June 3, 2026 at 12:46 am

    I digged a little deeper and the underlying problem here is that I am trying to create a cross domain tracking link to another domain in another iframe instead of a whole new window (the iframe is created by fancybox). So instead of using _link I should use _getLinkerUrl as described here:

    https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite#trackingIFrames

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so I have a site that uses the google maps API, and I
I'm working on a site that uses Google Analytics. On most of the pages
I have a site that uses a large centered background image, which naturally loads
I have a site that uses a menu control tied to a sitemapdatasource which
I have a PHP site that uses a fairly common authentication scheme. The entire
I have an application that uses Django 1.3 installed in python's site-packages. I want
Google Analytics tracks users through a client-side javascript that customers place on their site.
I have a form that uses google docs and when you submit it will
I have a django site within virtual environment that uses Python 2.6 installed with
I have problem where google chrome is showing: The site uses SSL, but Google

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.