# in your site.yml specify
#
# google_analytics:
# account: UA-something
# anonymizeIp: true
# bounceTime: 15
# demographics: true
# linkAttribution: true
#
# of course only "account" is required
module Awestruct
module Extensions
module GoogleAnalytics
def google_analytics_async()
# deprecated
$LOG.warn "google_analytics_async is deprecated. Please use google_analytics or google_analytics_universal." if $LOG.warn?
google_analytics()
end
def google_analytics(options={})
options = defaults(options)
html = ''
html += %Q(\n]
html
end
def google_analytics_universal(options={})
options = defaults(options)
html = ''
html += %Q(\n)
html
end
private
def defaults(options)
options = site.google_analytics.merge(options) if site.google_analytics.is_a?(Hash)
options = Hash[options.map{ |k, v| [k.to_sym, v] }]
if site.google_analytics_anonymize
# deprecated
$LOG.warn "Syntax has changed to site.google_analytics = { :anonymizeIp => true }" if $LOG.warn?
options[:anonymizeIp] = true
end
if site.google_analytics.is_a?(String)
# deprecated
$LOG.warn "Syntax has changed to site.google_analytics = { :account => '#{site.google_analytics}' }" if $LOG.warn?
options[:account] = site.google_analytics
end
options
end
end
end
end