amariotti.com

  • about
  • blog
  • portfolio
  • resumé
  • modules
  • contact
Home › Blogs › amariotti's blog

Recent blog posts

  • Text Formatter Module
  • Cool Apache ReWrite Trick
  • New RSS Feed
  • Find My iPhone
  • Congratulations, Drupal!
  • Re-Launched on Drupal 6
  • Copying + Pasting from Word into Drupal
  • Page Not Found on Node Creation
  • 1 Year
  • Happy Birthday WWW!
more

Recent comments

  • Turning off PHP suhosin
    36 weeks 1 day ago
  • The code for D5 is posted
    36 weeks 3 days ago
  • Repost the code please :)
    37 weeks 9 hours ago
  • Hi, very nice post. I have
    38 weeks 3 days ago
  • Great post! I'll subscribe
    38 weeks 5 days ago
  • Cool! It works perfectly..
    40 weeks 13 hours ago
  • I'm having the same problem.
    40 weeks 5 days ago
  • Hello again. It's working but
    40 weeks 6 days ago
  • I'm having the same issue, it
    40 weeks 6 days ago
  • Yes, when I open the page I
    40 weeks 6 days ago

Blog tags

drupal drupal 6 drupal issue liquidweb module modules that I love os x random rss Salesforce.com software theming
more tags

Multiple Google Analytics Accounts with the Domain Access Module

amariotti — Wed, 01/14/2009 - 17:08

A month or so ago I started my first site on Drupal 6.x. I was very excited about this for a number of reasons which I will mention on another day–in another post. Once it was installed I went straght for the Domain Access module. For those of that are familiar with it, you know that it's a pretty slick module with a lot of good functionality. It allows you to run multiple Drupal 6 sites off the same code base and database. I understand that there is always the multi-site option, but I wanted to try something a little more integrated and clean. That's all I'll say about the Domain Access module (I will post about it in the next few weeks, because there's lots to say).

Anyway, so say that you wanted to use the Domain Access module with multiple-sites/sub-domains but you wanted them each to have a different Google Analytics Account Number (UA-xxxx-x)? My reasoning for this was so that I could track my sites totally independent of each other. Google added a feature that will allow you to seperate your analytics by domain name, which works, but wasn't the solution I wanted. Then it was time for digging.

I came across a post of Drupal.org that gave me a good start. I had to keep searching for a few days (on and off) before I was able to find a post that almost got me there. And finally, after a few typos in the function, it all came together. And here's how you can do it on your Drupal 6.x, or 5.x if I remember correctly, site.

Create a domain_conf.inc file in your /sites/all/modules/domain/domain_conf folder. The function can be found in the attached txt file on this post.

After you follow those steps be sure and enable the "Domain Configuration" module on your modules page. Once it's enabled you will see a new field (shown below) show up on your domain's settings page at: admin/build/domain/conf/(domain id).

Then you're done! Enjoy!

AttachmentSize
domain_conf.inc.txt1.08 KB
  • drupal
  • module
  • amariotti's blog
  • 4388 reads

THis is a dead link. Can

Anonymous (not verified) — Tue, 04/14/2009 - 06:03

THis is a dead link. Can you please repost? Thank you for contributing this. This is one of those things you don't think about until you've already developed the site with DA.

J.

  • reply

It's back up. Sorry about

amariotti — Sat, 04/18/2009 - 09:10

It's back up. Sorry about that.

  • reply

hi, thank you for the code

Jeff Stern (not verified) — Mon, 04/27/2009 - 13:46

hi, thank you for the code and for figuring this out! we have the same situation so you saved us a lot of time searching for the same answers.. much appreciated.

just a couple of questions:

1) you said, "Google added a feature that will allow you to separate your analytics by domain name, which works, but wasn't the solution I wanted." Why not? Just interested..

2) there is a page, "How do I track all of the subdomains for my site in one profile?", here:

http://www.google.com/support/analytics/bin/answer.py?answer=55524

which sort of gets at the thing you *didn't* want to do -- which is have all the sub-domains use the same UA--xxxx-x ..

Even though we have several sites (one for each department at our university), we're thinking of still going this route, because it might make it easier for us to get *totals* across all the sites this way. but we haven't figured out how to get that "pageTracker._setDomainName(".example.com");" line in..

Any thoughts?

Thanks again..

  • reply

I just went through and typed

amariotti — Tue, 04/28/2009 - 00:50

I just went through and typed up a reply and accidentally opened up your link not thinking that it would kill my text. Stupid WYSIWYG editors like to screw things up. :)

Anyway, what I was saying was that my reasoning was mainly because I liked to have our primary domain seperate from the other sites on our campus to keep things clean. I liked to be able to login to my GA account and see a snapshot of my stats for all of my sites at a glance. Our marketing team also like to be able to see that data at a glance upon logging in.

Google's Advanced Segments features really is cool, and allows you to do a ton of different things with the data that is retrieved. I tried it, saw that it worked, and decided to go a different route for unknown reasons. The bottom line was that I didn't want all of that data bundled into one account. That's it!

I may invesigate things a little further down the road when we get more program websites up for our College, for now we'll stick with individualizing each site.

  • reply

MAny thanks for sharing.

everest poker (not verified) — Tue, 05/12/2009 - 02:28

MAny thanks for sharing.

  • reply

It's back up. Sorry about

Anonymous (not verified) — Sun, 05/24/2009 - 08:22

It's back up. Sorry about that.

  • reply

Hello and thanks for the

Carlos (not verified) — Thu, 05/28/2009 - 08:28

Hello and thanks for the code. I have to report an issue with this, I have two differents website (one with Drupal 5.x and another with Drupal 6.x) and in both I have the same problem. I open the domain settings page in the domain list and enter the code in the google analytics field. Then I click on the submit button and the page reloads saving the settings but the field is again with the UA- instead the code I've just about inserted.

Any idea why this happens?

  • reply

I'm not sure I'm

amariotti — Thu, 05/28/2009 - 10:20

I'm not sure I'm understanding you correctly here. So when you save it you are seeing a "UA-" replaced by the code you entered on your settings page?

  • reply

Yes, when I open the page I

Carlos (not verified) — Thu, 05/28/2009 - 10:24

Yes, when I open the page I replace the default value (UA-) by my Google Analytics code (UA-xxxxxx), then I submit the form and when it reloads, the field has again the default value (UA-).

  • reply

I'm having the same issue, it

amariotti — Thu, 05/28/2009 - 10:41

I'm having the same issue, it looks like. It appears to still be saving and loading on my site. Have you checked to see if the code is actually being recognized by Google Analytics? Check that and see if the code is being embedded. If it is then we can narrow down the issue a little bit.

  • reply

Hello again. It's working but

Carlos (not verified) — Fri, 05/29/2009 - 03:45

Hello again. It's working but I have to configure the Google Analytics in Google Analytics module settings instead Domain configuration settings. I can assing a different code for each domain (similar as multilanguage behaivor), I enter to the subdomain1.example.com, go to the Google Analytics domain settings and assing a code. After that I enter to subdomain2.example.com and I can assing a different code...

Strange, isn't it?

  • reply

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <b> <p> <br>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You may use <swf file="song.mp3"> to display Flash files inline

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
3 + 11 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
  • about
  • blog
  • portfolio
  • resumé
  • modules
  • contact