Could you make this module compatible with Domain Access, so that the user can select a different profile for each domain?

See the following discussion for an explanation of how Domain Access support was added to the Google Analytics module:

http://drupal.org/node/547390

Post #19 contains a module that adds a Google Analytics account number box to the individual domain settings screens. Would like to have a select box in this screen that would allow the user to select the GA profile he wants to use for each domain.

CommentFileSizeAuthor
#9 domain-conf-1063532-9.patch958 bytesmallezie
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mstrelan’s picture

+1

raspberryman’s picture

Assigned: Unassigned » grendzy
grendzy’s picture

Project: Google Analytics API » Google Analytics Reports
Version: 6.x-1.x-dev »
grendzy’s picture

Version: » 6.x-1.x-dev

anyone willing to research this one? Some API docs for Domain Access or code examples would be helpful. #547390: Domain Access & Separate Google Analytics Accounts is not very useful since it contains patches to the Domain Access project itself, and not contrib modules.

aaron1234nz’s picture

Status: Active » Needs review

This code will add both the per-domain settings for Google Analytics Reports. This could easily be rolled into this module. The hook will only ever fire if the domain_access module is installed.

I'm running this code on one of my domain access sites and works a treat.


/**
* Implement hook_domainbatch().
*
* Add Google Analytics API to Domain Conf.
*/
function MODULENAME_domainbatch() {
  $batch = array();
  if (module_exists('google_analytics_api')) {
    $account = google_analytics_api_account_data();
    $profile_id = variable_get('google_analytics_reports_profile_id', 0);

    $options = array();
    foreach ($account->results as $profile_key => $profile) {
      $options[$profile_key] = theme('google_analytics_api_profile_label', $profile);
    }

    $batch['google_analytics_reports_profile_id'] = array(
      '#form' => array(
        '#type' => 'select',
        '#title' => t('Reports profile'),
        '#options' => $options,
        '#default_value' => $profile_id,
        '#description' => t("Choose your Google Analytics profile.  The currently active profile is: %profile", array('%profile' => theme('google_analytics_api_profile_label', $account->results[$profile_id]))),
        '#required' => TRUE,
      ),
      '#domain_action' => 'domain_conf',
      '#meta_description' => t('Set Google Analytics report profile for each domain.'),
      '#variable' => 'google_analytics_reports_profile_id',
      '#data_type' => 'string',
      '#weight' => -1,
      '#group' => t('Google Analytics'),
      '#update_all' => TRUE,
      '#module' => t('Domain Analytics Reports'),
    );
  }
  return $batch;
}
grendzy’s picture

Status: Needs review » Patch (to be ported)
grendzy’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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

mallezie’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Category: feature » bug
Status: Closed (fixed) » Needs review
FileSize
958 bytes

Domain access 3.3 uses hook_domain_conf() for creating this.
Code in Google_analytics reports uses hook_domainconf() (which is obviously not working).
Patch attached.

grendzy’s picture

Status: Needs review » Closed (fixed)

Thanks for the report. Let's make a separate issue: #1423188: Update to domain access API version 3