2

I am working on a Drupal mulsite project (using single database) and using Google Analytics module for this.

I have follow the below steps for GA configuration:

  1. Created a domain name example1.com and a sub-domain name example2.com.
  2. Create an account on GA and create property for both of this domain name in GA account. Both property give me two different Tracking ID (same as below screenshot).

enter image description here

  1. Into the configuration setting of GA from drupal admin section I have added Web Property ID of example1.com and into domain setting added both the domain name example1.com and example2.com into the section of List of top-level domains (a same as attached screenshot).

enter image description here

Now this configuration is only working for emample1.com, not for example2.com. So can anyone please tell me how can I use Web Property ID of domain exmaple2.php to get the result?

  • I take it doesn't work because those domains have two different UAs, while the module allows you to enter just one. – kiamlaluno Jun 1 '15 at 9:35
1

As Kiamlaluno states, this is likely caused by the fact that the module only allows one UA, while you are trying to track two domains. According to the GA module documentation it can be overridden using code like this in settings.php:

<?php
// Override Google Analytics Web Property ID per hostname. 
// Hostnames need to be lower-case!
switch ($_SERVER['HTTP_HOST']) {
  case 'www.example.com':
  case 'www.example.net':
  case 'forum.example.net':
    $conf['googleanalytics_account'] = 'UA-123456-2';
    break;

  case 'www.example.org':
    $conf['googleanalytics_account'] = 'UA-123456-3';
    break;

  default:
    $conf['googleanalytics_account'] = 'UA-123456-1';
}
?>

Documentation can be found here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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