<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>hi, it&#39;s mike</title>
    <link>https://mike.puddingtime.org/tags/rugalytics/</link>
    <description>Recent content on hi, it&#39;s mike</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>mike@puddingtime.org (mike)</managingEditor>
    <webMaster>mike@puddingtime.org (mike)</webMaster>
    <copyright>© 2026, mike</copyright>
    <lastBuildDate>Mon, 02 Feb 2009 09:09:40 +0000</lastBuildDate>
    <atom:link href="https://mike.puddingtime.org/tags/rugalytics/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Tracking Specific Domains in Google Analytics/Google Docs</title>
      <link>https://mike.puddingtime.org/posts/2009-02-02-tracking-specific-domains-in-google-analytics/</link>
      <pubDate>Mon, 02 Feb 2009 09:09:40 +0000</pubDate><author>mike@puddingtime.org (mike)</author>
      <guid>https://mike.puddingtime.org/posts/2009-02-02-tracking-specific-domains-in-google-analytics/</guid>
      
      <description>Say you want to keep an eye on a given set of referrers in Google Analytics:
[sourcecode language=‘ruby’]
!/usr/bin/ruby require &#39;rubygems&#39; require &#34;google_spreadsheet&#34; require &#39;rugalytics&#39; session = GoogleSpreadsheet.login(&#34;GOOGLE USERNAME&#34;, &#34;GOOGLE PASSWORD&#34;) Rugalytics.login &#39;ANALYTICS USERNAME&#39;, …</description>
      <content:encoded><![CDATA[<p>Say you want to keep an eye on a given set of referrers in Google Analytics:</p>
<div>
<p>[sourcecode language=&lsquo;ruby&rsquo;]</p>
<pre><code>!/usr/bin/ruby

require 'rubygems'

require &quot;google_spreadsheet&quot;

require 'rugalytics'  

session = GoogleSpreadsheet.login(&quot;GOOGLE USERNAME&quot;, &quot;GOOGLE PASSWORD&quot;)

Rugalytics.login 'ANALYTICS USERNAME', 'ANALYTICS PASSWORD'  

 the key is derived from the 'key' param in the URL, e.g.

 http://spreadsheets.google.com/ccc?key=THE KEY&amp;hl=en

ws = session.spreadsheet_by_key(&quot;SPREADSHEET KEY&quot;).worksheets

domains = [ARRAY OF DOMAINS]

start_cell = 2

@profiles = {'ACCOUNT' =&gt; 'PROFILE', 

             'ACCOUNT2' =&gt; 'PROFILE2', 

             }



   @profiles.each do | a,r |

       sheet_title = a

       sheet = ws.find { |s| s.title == sheet_title }

       profile = Rugalytics.find_profile(a,r)

i = 12

  while i &gt; 0 

      range_start = Date.today - i.months

      range_end = range_start + 1.months - 1.days

      report = profile.referring_sources_report :rows=&gt;1000, :from =&gt; range_start, :to =&gt; range_end

      col = sheet.num_cols + 1

      report.items.each do |r|

         if social_domains.include?(r.source)

           row = social_domains.index(r.source) + 2

           sheet[1, col] = &quot;{range_start} - {range_end}&quot;

           sheet[row, col] = r.visits.to_i

           sheet.save

         end

     end

    i = i - 1 

  end

end

[/sourcecode]
</code></pre>
</div>
<p>It needs a little setup work up front:  You need a Google Spreadsheet, and the first column needs to be populated with the domains you populate the <code>domains</code> array with.  If you have more than one profile to track in Analytics, you need to create a worksheet with the name of each profile in your spreadsheet.</p>
<p>I&rsquo;d rather be using the more full-featured <a href="http://roo.rubyforge.org/rdoc/index.html">roo</a> to handle the spreadsheet part, but it isn&rsquo;t playing nice with <a href="http://github.com/robmckinnon/rugalytics/tree/master">rugalytics</a> at the moment.  I wrote both the authors, so maybe something good will come of that.</p>
<p>#google analytics #ruby #rugalytics #spreadsheet</p>
<p><em><a href="mailto:mike@puddingtime.org?subject=Re%3A%20Tracking%20Specific%20Domains%20in%20Google%20Analytics%2FGoogle%20Docs">Drop a line about this</a>.</em></p>]]></content:encoded>
    </item>
  </channel>
</rss>
