PKU8GqD D pdata/__init__.py# -*- coding: utf-8 -*- # vim: sw=4 ts=4 fenc=utf-8 # ============================================================================= # $Id: __init__.py 45 2008-02-21 18:10:38Z s0undt3ch $ # ============================================================================= # $URL: http://devnull.ufsoft.org/svn/GoogleAnalyticsWidget/trunk/__init__.py $ # $LastChangedDate: 2008-02-21 18:10:38 +0000 (Thu, 21 Feb 2008) $ # $Rev: 45 $ # $LastChangedBy: s0undt3ch $ # ============================================================================= # Copyright (C) 2007 Ufsoft.org - Pedro Algarvio # # Please view LICENSE for additional licensing information. # ============================================================================= # https://www.google.com/support/googleanalytics/bin/answer.py?answer=55585&topic=10981 from os.path import join, dirname from textpress.widgets import Widget from textpress.api import * SHARED_FILES = join(dirname(__file__), 'shared') TEMPLATES = join(dirname(__file__), 'templates') class GoogleAnalyticsWidget(Widget): __metaclass__ = cache.make_metaclass(vary=('user',)) NAME = 'get_google_analytics' TEMPLATE = 'google_analytics.html' def __init__(self, uid='', admin_logging=False, extensions='', outbound_link_tracking=True, tracking_domain_name='', google_external_path='/external/'): self.uid = uid self.admin_logging = admin_logging self.extensions = extensions self.outbound_link_tracking = outbound_link_tracking self.tracking_domain_name = tracking_domain_name self.google_external_path = google_external_path @staticmethod def get_display_name(): return _('Google Analytics') @staticmethod def configure_widget(initial_args, request): args = form = initial_args.copy() error = None if request.method == 'POST': args['uid'] = request.form.get('uid', '') if not args['uid']: error = _("You need to enter your google analytics UUID") args['extensions'] = request.form.get('extensions', '') args['admin_logging'] = request.form.get('admin_logging') == 'yes' args['outbound_link_tracking'] = request.form.get('outbound_link_tracking') == 'yes' args['tracking_domain_name'] = request.form.get('tracking_domain_name', '') args['google_external_path'] = request.form.get('google_external_path', '') if error is not None: args = None return args, render_template('admin/google_analytics.html', error=error, form=form) def setup(app, plugin): app.add_shared_exports('google_analytics', SHARED_FILES) app.add_template_searchpath(TEMPLATES) app.add_widget(GoogleAnalyticsWidget) PK0Z8zӥpdata/metadata.txtName: Google Analytics Widget Author: Pedro Algarvio, aka, s0undt3ch License: BSD Version: 0.1 Description: Adds the necessary JavaScript code to enable\ Google's Analytics.\ After enabling this plugin visit the widgets page, activate the Google\ Analytics widget and at least, enter your Google Analytics' UID.
\
Contribute Back
\ If you think this plugin is usefull and would like\ to contribute back, feel free to click on the donate button.\ This is optional.\ \
\ \ \ \ \


\
\

PKgT8E4%pdata/templates/google_analytics.html{% extends 'widgets/base.html' %} {% block title %}{% endblock %} {% block body %} {% if (request.user.is_manager and widget.admin_logging) or (not request.user.is_manager) %} {% else %} {% endif %} {% endblock %} PKCZ8c_ +pdata/templates/admin/google_analytics.html{% for error in errors %}
{{ error }}
{% endfor %}
This code is based on the new Google Analytics javascript code. Consider that when going to the Google Analytics FAQ if needed.
{% trans "UID" %}
{{ h.input_field('uid', form.uid) }}
Enter your Google Analytics' UID in this box. The UID is needed for Google Analytics to log your website stats. Your UID can be found by looking in the JavaScript Google Analytics gives you to put on your page. Look for your UID in between var pageTracker = _gat._getTracker("UA-111111-11"); in the javascript.
In this example you would put UA-11111-1 in the UID box.
{% trans "Admin Logging" %}
{{ h.checkbox('admin_logging', form.admin_logging) }}
Disabling this option will prevent all logged in TextPress admins from showing up on your Google Analytics reports. A TextPress admin is defined as a user with a level of 4 or higher.
{% trans "Outbound Link Tracking" %}
{{ h.checkbox('outbound_link_tracking', form.outbound_link_tracking) }}
Disabling this option will turn off the tracking of outbound links. It's recommended not to disable this option unless you're a privacy advocate (now why would you be using Google Analytics in the first place?) or it's causing some kind of weird issue.
{% trans "Google Analytics External Path Prefix" %}
{{ h.input_field('google_external_path', form.google_external_path) }}
This will be the path shown on Google Analytics regarding external links. Consider the following link:
<a href="http://textpress.pocoo.org/">TextPress</a>
The above link will be shown as {{ form.google_external_path }}textpress.pocoo.org/.
This way you will be able to track outgoing links.
Outbound link tracking must be enabled for external links to be tracked.
{% trans "Download Extensions To Track" %}
{{ h.input_field('extensions', form.extensions) }}
Enter any extensions of files you would like to be tracked as a download. For example to track all MP3s and PDFs enter mp3,pdf.
Outbound link tracking must be enabled for downloads to be tracked.
{% trans "Tracking Domain Name" %}
{{ h.input_field('tracking_domain_name', form.tracking_domain_name) }}
If you're tracking multiple subdomains with the same Google Analytics profile, like what's talked about here, enter your main domain here. For more info, please visit the previous link.
PK[8ksTEXTPRESS_PLUGINgoogle_analyticsPK[8܃TEXTPRESS_PACKAGE1PKU8GqD D pdata/__init__.pyPK0Z8zӥs pdata/metadata.txtPKgT8E4%Hpdata/templates/google_analytics.htmlPKCZ8c_ ++"pdata/templates/admin/google_analytics.htmlPK[8ks>0TEXTPRESS_PLUGINPK[8܃|0TEXTPRESS_PACKAGEPK0