Domain Access & Separate Google Analytics Accounts

yt2s - August 12, 2009 - 17:39
Project:Domain Access
Version:6.x-2.0-rc8
Component:- Domain Conf
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Opening a new issue per this comment...

Using Domain Access and Google Analytics. In order to maintain separate Google Analytics accounts on subdomains I followed this advice and placed the following code into a domain_conf.inc file:

<?php
/**
* Implements hook_domainconf() to add the google analytics account number per domain.
*/

function googleanalytics_domainconf() {
 
$form['googleanalytics'] = array(
   
'#type' => 'fieldset',
   
'#title' => t('Google Analytics settings'),
   
'#collapsible' => TRUE,
   
'#collapsed' => FALSE,
  );

 
$form['googleanalytics']['googleanalytics_account'] = array(
   
'#type' => 'textfield',
   
'#title' => t('Google Analytics account number'),
   
'#default_value' => variable_get('google_analytics', 'UA-'),
   
'#size' => 15,
   
'#maxlength' => 20,
   
'#required' => TRUE,
   
'#description' => t('The account number is unique to the websites domain. Click the <strong>Edit</strong> link in your Google Analytics account next to the appropriate profile on the <strong>Analytics Settings</strong> page, then select <strong>Check Status</strong> at the top-right of the table to find the account number (UA-xxxx-x) of your site. You can obtain a user account from the <a href="@url">Google Analytics</a> website.', array('@url' => 'http://www.google.com/analytics/')),
  );
  return
$form;
}
?>

The end result is the separation is working as expected within the Google accounts using individual UA-#'s for each the primary domain and subdomains. There is however a problem within the Drupal site itself:

At admin => build => domain => conf => "domain #", the Google Analytics account number field does allow input of the UA-# and it is recorded in the db and Google is receiving data to that specific account; however, the text field itself does not remain populated with the previously entered value upon revisiting or refreshing the conf page again. This creates a bit of a problem when the user attempts to update information in other fields on the domain conf page, as the user will also be required to re-enter the correct UA-# value again, or else the value will be unset.

What is very interesting, is at admin => settings => googleanalytics. If the individual UA-# values have been entered and saved from the domain conf page (above), the correct values are then pre-populated, as they should be, in the Google Analytics account number field in the respective domain's Google Analytics module configuration pages... e.g. example.com/admin/settings/googleanalytics, domain1.example.com/admin/settings/googleanalytics, domain2.example.com/admin/settings/googleanalytics, etc.

Is there a solution to getting the previously entered UA-#'s to also pre-populate the Google Analytics account number field on the domain conf pages as well?

#1

agentrickard - August 12, 2009 - 18:17

It is possible that the switch to using DomainBatch to define these elements affected the form handling.

See #545946: Domain Mollom for another way to expose your data to Domain Conf.

If this is the case, we have to update the documentation.

#2

agentrickard - August 12, 2009 - 22:34
Category:support request» bug report
Status:active» needs review

Nope, this is a bug in domain conf. This patch should fix it. Apply from the root domain directory.

AttachmentSize
547390-domain-conf.patch 2.05 KB

#3

yt2s - August 13, 2009 - 04:35

Worked like a champ! Thank you very much!

Side Note:   This patch applied to domain_conf.module (28 Jun 2009 V 1.49) starting on line 457.   I applied the patch manually instead to 6.x-2.0-rc8 domain_conf.module (14 Jun 2009 V 1.46) beginning on line 448.

#4

agentrickard - August 13, 2009 - 13:39
Status:needs review» patch (to be ported)

Yes, the patch is against HEAD, so this is fine.

Committed to HEAD. D5 version attached and needs a test.

AttachmentSize
547390-domain-conf-d5.patch 1.82 KB

#5

matteoraggi - September 10, 2009 - 22:03

It will be on 6.x-2.0-RC10 ?

#6

agentrickard - September 11, 2009 - 13:40

It is already in rc9. There will be no rc10, just a 6.x.2.0 final.

#7

matteoraggi - September 11, 2009 - 15:31

Nice to read it, so to add multiple google analytics codes, I?ll need to follow these up instructions, because I don't find into user interface the possibility to do it, for example there:
admin/build/domain/batch
admin/settings/googleanalytics
There will be always need to modify domain_conf.inc or in future we'll be free to use UI.?

#8

croryx - September 11, 2009 - 15:44

It is available in the UI (at least using the patch on rc8) at:
/admin/build/domain/conf/THEDOMAINID

or just go to Administer>Site building>Domains and click on the 'settings' link for the domain you want to edit. There should be a Google Analytics settings box at the bottom for you to enter your UA account number.

#9

matteoraggi - September 11, 2009 - 16:27

I'm using rc9 without patch and I can't find it in UI, I have attached what I see on this page.

AttachmentSize
ui.jpg 10.08 KB

#10

croryx - September 11, 2009 - 16:44

I may have misread your original comment, sorry. You do need the domain_conf.inc file above for this to work.

#11

agentrickard - September 11, 2009 - 17:02

You have to implement the hook yourself, or convince the Google Analytics maintainer to put it in the module.

#12

matteoraggi - September 11, 2009 - 17:23

I have done it now, with my bad english:
http://drupal.org/node/574930

#13

agentrickard - October 31, 2009 - 19:31
Status:patch (to be ported)» fixed

D5 does not pass in the null option, so this is done.

#14

System Message - November 14, 2009 - 19:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.