diff --git a/analytical/chartbeat/__init__.py b/analytical/chartbeat/__init__.py deleted file mode 100644 index 7fd9add..0000000 --- a/analytical/chartbeat/__init__.py +++ /dev/null @@ -1,145 +0,0 @@ -""" -============================= -Chartbeat -- traffic analysis -============================= - -Chartbeat_ provides real-time analytics to websites and blogs. It shows -visitors, load times, and referring sites on a minute-by-minute basis. -The service also provides alerts the second your website crashes or -slows to a crawl. - -.. _Chartbeat: http://www.chartbeat.com/ - - -.. chartbeat-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`chartbeat-configuration`. - -In order to use the template tags, you need to add -:mod:`analytical.chartbeat` to the installed applications list in the -project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.chartbeat', - ... - ] - -The Chartbeat tracking code is inserted into templates using template -tags. At the top of the template, load the :mod:`chartbeat` template -tag library. Then insert the :ttag:`chartbeat_top` tag at the top of -the head section, and the :ttag:`chartbeat_bottom` tag at the bottom of -the body section:: - - {% load chartbeat %} - - - {% chartbeat_top %} - - ... - - {% chartbeat_bottom %} - - - -Because these tags are used to measure page loading time, it is -important to place them as close as possible to the start and end of the -document. - -.. _chartbeat-configuration: - -Configuration -============= - -Before you can use the Chartbeat integration, you must first set your -User ID. - - -.. _chartbeat-user-id: - -Setting the User ID -------------------- - -Your Chartbeat account has a unique User ID. You can find your User ID -by visiting the Chartbeat `Add New Site`_ page. The second code snippet -contains a line that looks like this:: - - var _sf_async_config={uid:XXXXX,domain:"YYYYYYYYYY"}; - -Here, ``XXXXX`` is your User ID. Set :const:`CHARTBEAT_USER_ID` in the -project :file:`settings.py` file:: - - CHARTBEAT_SITE_ID = 'XXXXX' - -If you do not set a User ID, the tracking code will not be rendered. - -.. _`Add New Site`: http://chartbeat.com/code/ - - -.. _chartbeat-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _chartbeat-domain: - -Setting the domain ------------------- - -The Javascript tracking code can send the website domain to Chartbeat. -If you use multiple subdomains this enables you to treat them as one -website in Chartbeat. If your project uses the sites framework, the -domain name of the current :class:`~django.contrib.sites.models.Site` -will be passed to Chartbeat automatically. You can modify this behavior -using the :const:`CHARTBEAT_AUTO_DOMAIN` setting:: - - CHARTBEAT_AUTO_DOMAIN = False - -Alternatively, you set the domain through the ``chartbeat_domain`` -context variable when you render the template:: - - context = RequestContext({'chartbeat_domain': 'example.com'}) - return some_template.render(context) - -It is annoying to do this for every view, so you may want to set it in -a context processor that you add to the -:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def chartbeat(request): - return {'chartbeat_domain': 'example.com'} - -The context domain overrides the domain from the current site. If no -domain is set, either explicitly or implicitly through the sites -framework, then no domain is sent, and Chartbeat will detect the domain -name from the URL. If your website uses just one domain, this will work -just fine. - - ----- - -Thanks go to Chartbeat for their support with the development of this -application. -""" - -chartbeat_service = { - 'head_top': ( - 'analytical.chartbeat.templatetags.chartbeat.ChartbeatTopNode', - 'top', - ), - 'body_bottom': ( - 'analytical.chartbeat.templatetags.chartbeat.ChartbeatBottomNode', - 'bottom', - ), -} diff --git a/analytical/chartbeat/templatetags/__init__.py b/analytical/chartbeat/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/clicky/__init__.py b/analytical/clicky/__init__.py deleted file mode 100644 index ff0a659..0000000 --- a/analytical/clicky/__init__.py +++ /dev/null @@ -1,151 +0,0 @@ -""" -========================== -Clicky -- traffic analysis -========================== - -Clicky_ is an online web analytics tool. It is similar to Google -Analytics in that it provides statistics on who is visiting your website -and what they are doing. Clicky provides its data in real time and is -designed to be very easy to use. - -.. _Clicky: http://getclicky.com/ - - -.. clicky-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`clicky-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.clicky` to the installed applications list in the -project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.clicky', - ... - ] - -The Clicky tracking code is inserted into templates using a template -tag. Load the :mod:`clicky` template tag library and insert the -:ttag:`clicky` tag. Because every page that you want to track must -have the tag, it is useful to add it to your base template. Insert -the tag at the bottom of the HTML body:: - - {% load clicky %} - ... - {% clicky %} - - - - -.. _clicky-configuration: - -Configuration -============= - -Before you can use the Clicky integration, you must first set your -website Site ID. You can also customize the data that Clicky tracks. - - -.. _clicky-site-id: - -Setting the Site ID -------------------- - -Every website you track with Clicky gets its own Site ID, and the -:ttag:`clicky` tag will include it in the rendered Javascript code. -You can find the Site ID in the *Info* tab of the website *Preferences* -page, in your Clicky account. Set :const:`CLICKY_SITE_ID` in the -project :file:`settings.py` file:: - - CLICKY_SITE_ID = 'XXXXXXXX' - -If you do not set a Site ID, the tracking code will not be rendered. - - -.. _clicky-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _clicky-custom-data: - -Custom data ------------ - -As described in the Clicky `customized tracking`_ documentation page, -the data that is tracked by Clicky can be customized by setting the -:data:`clicky_custom` Javascript variable before loading the tracking -code. Using template context variables, you can let the :ttag:`clicky` -tag pass custom data to Clicky automatically. You can set the context -variables in your view when your render a template containing the -tracking code:: - - context = RequestContext({'clicky_title': 'A better page title'}) - return some_template.render(context) - -It is annoying to do this for every view, so you may want to set custom -properties in a context processor that you add to the -:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def clicky_global_properties(request): - return {'clicky_timeout': 10} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. - -Here is a table with the most important variables. All variable listed -on the `customized tracking`_ documentation page can be set by replacing -``clicky_custom.`` with ``clicky_``. - -================== =============== =================================== -Context variable Clicky property Description -================== =============== =================================== -``clicky_session`` session_ Session data. A dictionary - containing ``username`` and/or - ``group`` keys. ------------------- --------------- ----------------------------------- -``clicky_goal`` goal_ A succeeded goal. A dictionary - containing ``id`` and ``revenue`` - keys. ------------------- --------------- ----------------------------------- -``clicky_href`` href_ The URL as tracked by Clicky. - Default is the page URL. ------------------- --------------- ----------------------------------- -``clicky_title`` title_ The page title as tracked by - Clicky. Default is the HTML title. -================== =============== =================================== - -By default, the username of an authenticated user is passed to Clicky -automatically in the session_ property, unless that property was set -explicitly. See :data:`ANALYTICAL_AUTO_IDENTIFY`. - -.. _`customized tracking`: http://getclicky.com/help/customization -.. _session: http://getclicky.com/help/customization#session -.. _goal: http://getclicky.com/help/customization#goal -.. _href: http://getclicky.com/help/customization#href -.. _title: http://getclicky.com/help/customization#title - - ----- - -Thanks go to Clicky for their support with the development of this -application. -""" - -clicky_service = { - 'body_bottom': 'analytical.clicky.templatetags.clicky.ClickyNode', -} diff --git a/analytical/clicky/templatetags/__init__.py b/analytical/clicky/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/crazy_egg/__init__.py b/analytical/crazy_egg/__init__.py deleted file mode 100644 index 1da261e..0000000 --- a/analytical/crazy_egg/__init__.py +++ /dev/null @@ -1,125 +0,0 @@ -""" -================================== -Crazy Egg -- visual click tracking -================================== - -`Crazy Egg`_ is an easy to use hosted web application that visualizes -website clicks using heatmaps. It allows you to discover the areas of -web pages that are most important to your visitors. - -.. _`Crazy Egg`: http://www.crazyegg.com/ - - -.. crazy-egg-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`crazy-egg-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.crazy_egg` to the installed applications list in the -project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.crazy_egg', - ... - ] - -The Crazy Egg tracking code is inserted into templates using a template -tag. Load the :mod:`crazy_egg` template tag library and insert the -:ttag:`crazy_egg` tag. Because every page that you want to track must -have the tag, it is useful to add it to your base template. Insert -the tag at the bottom of the HTML body:: - - {% load crazy_egg %} - ... - {% crazy_egg %} - - - - -.. _crazy-egg-configuration: - -Configuration -============= - -Before you can use the Crazy Egg integration, you must first set your -account number. You can also segment the click analysis through user -variables. - - -.. _crazy-egg-account-number: - -Setting the account number --------------------------- - -Crazy Egg gives you a unique account number, and the :ttag:`crazy egg` -tag will include it in the rendered Javascript code. You can find your -account number by clicking the link named "What's my code?" in the -dashboard of your Crazy Egg account. Set -:const:`CRAZY_EGG_ACCOUNT_NUMBER` in the project :file:`settings.py` -file:: - - CRAZY_EGG_ACCOUNT_NUMBER = 'XXXXXXXX' - -If you do not set an account number, the tracking code will not be -rendered. - - -.. _crazy-egg-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _crazy-egg-uservars: - -User variables --------------- - -Crazy Egg can segment clicks based on `user variables`_. If you want to -set a user variable, use the context variables ``crazy_egg_var1`` -through ``crazy_egg_var5`` when you render your template:: - - context = RequestContext({'crazy_egg_var1': 'red', - 'crazy_egg_var2': 'male'}) - return some_template.render(context) - -If you use the same user variables in different views and its value can -be computed from the HTTP request, you can also set them in a context -processor that you add to the :data:`TEMPLATE_CONTEXT_PROCESSORS` list -in :file:`settings.py`:: - - def segment_on_ip_proto(request): - addr = request.META.get('HTTP_X_FORWARDED_FOR', - request.META.get('REMOTE_ADDR', '')) - proto = 'ipv6' if ':' in addr else 'ipv4' - return {'crazy_egg_var3': proto} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. - -.. _`user variables`: https://www.crazyegg.com/help/Setting_Up_A_Page_to_Track/How_do_I_set_the_values_of_User_Var_1_User_Var_2_etc_in_the_confetti_and_overlay_views/ - - ----- - -Thanks go to Crazy Egg for their support with the development of this -application. - -""" - -crazy_egg_service = { - 'body_bottom': 'analytical.crazy_egg.templatetags.crazy_egg.CrazyEggNode', -} diff --git a/analytical/crazy_egg/templatetags/__init__.py b/analytical/crazy_egg/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/google_analytics/__init__.py b/analytical/google_analytics/__init__.py deleted file mode 100644 index 1ffcf3f..0000000 --- a/analytical/google_analytics/__init__.py +++ /dev/null @@ -1,142 +0,0 @@ -""" -==================================== -Google Analytics -- traffic analysis -==================================== - -`Google Analytics`_ is the well-known web analytics service from -Google. The product is aimed more at marketers than webmasters or -technologists, supporting integration with AdWords and other e-commence -features. - -.. _`Google Analytics`: http://www.google.com/analytics/ - - -.. google-analytics-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`google-analytics-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.google_analytics` to the installed applications list in -the project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.google_analytics', - ... - ] - -The Google Analytics tracking code is inserted into templates using a -template tag. Load the :mod:`google_analytics` template tag library and -insert the :ttag:`google_analytics` tag. Because every page that you -want to track must have the tag, it is useful to add it to your base -template. Insert the tag at the bottom of the HTML head:: - - {% load google_analytics %} - - - ... - {% google_analytics %} - - ... - - -.. _google-analytics-configuration: - -Configuration -============= - -Before you can use the Google Analytics integration, you must first set -your website property ID. You can also add custom segments for Google -Analytics to track. - - -.. _google-analytics-property-id: - -Setting the property ID ------------------------ - -Every website you track with Google Analytics gets its own property ID, -and the :ttag:`google_analytics` tag will include it in the rendered -Javascript code. You can find the web property ID on the overview page -of your account. Set :const:`GOOGLE_ANALYTICS_PROPERTY_ID` in the -project :file:`settings.py` file:: - - GOOGLE_ANALYTICS_PROPERTY_ID = 'UA-XXXXXX-X' - -If you do not set a property ID, the tracking code will not be rendered. - - -.. _google-analytics-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _google-analytics-custom-variables: - -Custom variables ----------------- - -As described in the Google Analytics `custom variables`_ documentation -page, you can define custom segments. Using template context variables -``google_analytics_var1`` through ``google_analytics_var5``, you can let -the :ttag:`google_analytics` tag pass custom variables to Google -Analytics automatically. You can set the context variables in your view -when your render a template containing the tracking code:: - - context = RequestContext({'google_analytics_var1': ('gender', 'female'), - 'google_analytics_var2': ('visit', '1', SCOPE_SESSION)}) - return some_template.render(context) - -The value of the context variable is a tuple *(name, value, [scope])*. -The scope parameter is one of the -:const:`analytical.google_analytics.SCOPE_*` constants: - -================= ====== ============================================= -Constant Value Description -================= ====== ============================================= -``SCOPE_VISITOR`` 1 Distinguishes categories of visitors across - multiple sessions. -``SCOPE_SESSION`` 2 Ddistinguishes different visitor experiences - across sessions. -``SCOPE_PAGE`` 3 Defines page-level activity. -================= ====== ============================================= - -The default scope is :const:`~analytical.google_analytics.SCOPE_PAGE`. - -You may want to set custom variables in a context processor that you add -to the :data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def google_analytics_segment_language(request): - try: - return {'google_analytics_var3': request.LANGUAGE_CODE} - except AttributeError: - return {} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. - -.. _`custom variables`: http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html - -""" - -SCOPE_VISITOR = 1 -SCOPE_SESSION = 2 -SCOPE_PAGE = 3 - -google_analytics_service = { - 'head_bottom': 'analytical.google_analytics.templatetags.google_analytics' - '.GoogleAnalyticsNode', -} diff --git a/analytical/google_analytics/templatetags/__init__.py b/analytical/google_analytics/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/hubspot/templatetags/__init__.py b/analytical/hubspot/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/kiss_insights/__init__.py b/analytical/kiss_insights/__init__.py deleted file mode 100644 index 842e333..0000000 --- a/analytical/kiss_insights/__init__.py +++ /dev/null @@ -1,133 +0,0 @@ -""" -================================ -KISSinsights -- feedback surveys -================================ - -KISSinsights_ provides unobtrusive surveys that pop up from the bottom -right-hand corner of your website. Asking specific questions gets you -the targeted, actionable feedback you need to make your site better. - -.. _KISSinsights: http://www.kissinsights.com/ - - -.. kiss-insights-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`kiss-insights-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.kiss_insights` to the installed applications list in -the project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.kiss_insights', - ... - ] - -The KISSinsights survey code is inserted into templates using a template -tag. Load the :mod:`kiss_insights` template tag library and insert the -:ttag:`kiss_insights` tag. Because every page that you want to track -must have the tag, it is useful to add it to your base template. Insert -the tag at the bottom of the HTML body:: - - {% load kiss_insights %} - ... - - - {% kiss_insights %} - ... - - -.. _kiss-insights-configuration: - -Configuration -============= - -Before you can use the KISSinsights integration, you must first set your -account number and site code. - - -.. _kiss-insights-account-number: - -Setting the account number and site code ----------------------------------------- - -In order to install the survey code, you need to set your KISSinsights -account number and website code. The :ttag:`kiss_insights` tag will -include it in the rendered Javascript code. You can find the account -number and website code by visiting the code installation page of the -website you want to place the surveys on. You will see some HTML code -with a Javascript tag with a ``src`` attribute containing -``//s3.amazonaws.com/ki.js/XXXXX/YYY.js``. Here ``XXXXX`` is the -account number and ``YYY`` the website code. Set -:const:`KISS_INSIGHTS_ACCOUNT_NUMBER` and -:const:`KISS_INSIGHTS_WEBSITE_CODE` in the project :file:`settings.py` -file:: - - KISSINSIGHTS_ACCOUNT_NUMBER = 'XXXXX' - KISSINSIGHTS_SITE_CODE = 'XXX' - -If you do not set the account number and website code, the survey code -will not be rendered. - - -.. _kiss-insights-identity-user: - -Identifying authenticated users -------------------------------- - -If your websites identifies visitors, you can pass this information on -to KISSinsights so that you can tie survey submissions to customers. -By default, the username of an authenticated user is passed to -KISSinsights automatically. See :data:`ANALYTICAL_AUTO_IDENTIFY` for -important information about detecting authenticated visitors. - -You can also send the visitor identity yourself by adding the -``analytical_identity`` variable to the template context:: - - context = RequestContext({'analytical_identity': identity}) - return some_template.render(context) - -If you can derive the identity from the HTTP request, you can also use -a context processor that you add to the -:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def identify(request): - try: - return {'analytical_identity': request.user.email} - except AttributeError: - return {} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. - - -.. _kiss-insights-show-survey: - -Showing a specific survey -------------------------- - -KISSinsights can also be told to show a specific survey. You can let -the :ttag:`kiss_insights` tag include the code to select a survey by -passing the survey ID to the template in the -``kiss_insights_show_survey`` context variable:: - - context = RequestContext({'kiss_insights_show_survey': 1234}) - return some_template.render(context) - -For information about how to find the survey ID, see the explanation -on `"How can I show a survey after a custom trigger condition?"`_ on the -KISSinsights help page. - -.. _`"How can I show a survey after a custom trigger condition?"`: http://www.kissinsights.com/help#customer-trigger -""" - -kiss_insights_service = { - 'body_top': 'analytical.kiss_insights.templatetags.kiss_insights.KissInsightsNode', -} diff --git a/analytical/kiss_insights/templatetags/__init__.py b/analytical/kiss_insights/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/kiss_metrics/__init__.py b/analytical/kiss_metrics/__init__.py deleted file mode 100644 index f86a9a7..0000000 --- a/analytical/kiss_metrics/__init__.py +++ /dev/null @@ -1,117 +0,0 @@ -""" -============================== -KISSmetrics -- funnel analysis -============================== - -KISSmetrics_ is an easy to implement analytics solution that provides a -powerful visual representation of your customer lifecycle. Discover how -many visitors go from your landing page to pricing to sign up, and how -many drop out at each stage. - -.. _KISSmetrics: http://www.kissmetrics.com/ - - -.. kiss-metrics-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`kiss-metrics-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.kiss_metrics` to the installed applications list in -the project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.kiss_metrics', - ... - ] - -The KISSmetrics Javascript code is inserted into templates using a -template tag. Load the :mod:`kiss_metrics` template tag library and -insert the :ttag:`kiss_metrics` tag. Because every page that you want -to track must have the tag, it is useful to add it to your base -template. Insert the tag at the top of the HTML head:: - - {% load kiss_metrics %} - - - {% kiss_metrics %} - ... - - -.. _kiss-metrics-configuration: - -Configuration -============= - -Before you can use the KISSmetrics integration, you must first set your -API key. - - -.. _kiss-metrics-api-key: - -Setting the API key -------------------- - -Every website you track events for with KISSmetrics gets its own API -key, and the :ttag:`kiss_metrics` tag will include it in the rendered -Javascript code. You can find the website API key by visiting the -website *Product center* on your KISSmetrics dashboard. Set -:const:`KISS_METRICS_API_KEY` in the project :file:`settings.py` file:: - - KISS_METRICS_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' - -If you do not set an API key, the tracking code will not be rendered. - - -.. _kiss-metrics-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _kiss-metrics-identify-user: - -Identifying users ------------------ - -If your websites identifies visitors, you can pass this information on -to KISSmetrics so that you can tie events to users. By default, the -username of an authenticated user is passed to KISSmetrics -automatically. See :data:`ANALYTICAL_AUTO_IDENTIFY` for important -information about detecting authenticated visitors. - -You can also send the visitor identity yourself by adding the -``analytical_identity`` variable to the template context:: - - context = RequestContext({'analytical_identity': identity}) - return some_template.render(context) - -If you can derive the identity from the HTTP request, you can also use -a context processor that you add to the -:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def identify(request): - try: - return {'analytical_identity': request.user.email} - except AttributeError: - return {} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. -""" - -kiss_metrics_service = { - 'head_top': 'analytical.kiss_metrics.templatetags.kiss_metrics.KissMetricsNode', -} diff --git a/analytical/kiss_metrics/templatetags/__init__.py b/analytical/kiss_metrics/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/mixpanel/__init__.py b/analytical/mixpanel/__init__.py deleted file mode 100644 index 8d4cf4c..0000000 --- a/analytical/mixpanel/__init__.py +++ /dev/null @@ -1,116 +0,0 @@ -""" -========================== -Mixpanel -- event tracking -========================== - -Mixpanel_ tracks events and actions to see what features users are using -the most and how they are trending. You could use it for real-time -analysis of visitor retention or funnels. - -.. _Mixpanel: http://www.mixpanel.com/ - - -.. mixpanel-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`mixpanel-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.mixpanel` to the installed applications list in the -project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.mixpanel', - ... - ] - -The Mixpanel Javascript code is inserted into templates using a -template tag. Load the :mod:`mixpanel` template tag library and -insert the :ttag:`mixpanel` tag. Because every page that you want -to track must have the tag, it is useful to add it to your base -template. Insert the tag at the bottom of the HTML head:: - - {% load mixpanel %} - ... - {% mixpanel %} - - - ... - - -.. _mixpanel-configuration: - -Configuration -============= - -Before you can use the Mixpanel integration, you must first set your -token. - - -.. _mixpanel-api-key: - -Setting the token ------------------ - -Every website you track events for with Mixpanel gets its own token, -and the :ttag:`mixpanel` tag will include it in the rendered Javascript -code. You can find the project token on the Mixpanel *projects* page. -Set :const:`MIXPANEL_TOKEN` in the project :file:`settings.py` file:: - - MIXPANEL_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' - -If you do not set a token, the tracking code will not be rendered. - - -.. _mixpanel-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to track clicks from your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. - - -.. _mixpanel-identify-user: - -Identifying users ------------------ - -If your websites identifies visitors, you can pass this information on -to Mixpanel so that you can tie events to users. By default, the -username of an authenticated user is passed to Mixpanel automatically. -See :data:`ANALYTICAL_AUTO_IDENTIFY` for important information about -detecting authenticated visitors. - -You can also send the visitor identity yourself by adding the -``analytical_identity`` variable to the template context:: - - context = RequestContext({'analytical_identity': identity}) - return some_template.render(context) - -If you can derive the identity from the HTTP request, you can also use -a context processor that you add to the -:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: - - def identify(request): - try: - return {'analytical_identity': request.user.email} - except AttributeError: - return {} - -Just remember that if you set the same context variable in the -:class:`~django.template.context.RequestContext` constructor and in a -context processor, the latter clobbers the former. -""" - -mixpanel_service = { - 'head_bottom': 'analytical.mixpanel.templatetags.mixpanel.MixpanelNode', -} diff --git a/analytical/mixpanel/templatetags/__init__.py b/analytical/mixpanel/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/optimizely/__init__.py b/analytical/optimizely/__init__.py deleted file mode 100644 index 3deb75e..0000000 --- a/analytical/optimizely/__init__.py +++ /dev/null @@ -1,92 +0,0 @@ -""" -========================= -Optimizely -- A/B testing -========================= - -Optimizely_ is an easy way to implement A/B testing. Try different -decisions, images, layouts, and copy without touching your website code -and see exactly how your experiments are affecting pageviews, -retention and sales. - -.. _Optimizely: http://www.optimizely.com/ - - -.. optimizely-installation: - -Installation -============ - -You only need to do perform these steps if you are not using the -generic :ttag:`analytical.*` tags. If you are, skip to -:ref:`optimizely-configuration`. - -In order to use the template tag, you need to add -:mod:`analytical.optimizely` to the installed applications list in the -project :file:`settings.py` file:: - - INSTALLED_APPS = [ - ... - 'analytical.optimizely', - ... - ] - -The Optimizely Javascript code is inserted into templates using a -template tag. Load the :mod:`mixpanel` template tag library and insert -the :ttag:`optimizely` tag. Because every page that you want to track -must have the tag, it is useful to add it to your base template. -Insert the tag at the top of the HTML head:: - - {% load optimizely %} - - - {% optimizely %} - ... - - -.. _optimizely-configuration: - -Configuration -============= - -Before you can use the Optimizely integration, you must first set your -account number. - - -.. _optimizely-account-number: - -Setting the account number --------------------------- - -Optimizely gives you a unique account number, and the :ttag:`optimizely` -tag will include it in the rendered Javascript code. You can find your -account number by clicking the `Implementation` link in the top -right-hand corner of the Optimizely website. A pop-up window will -appear containing HTML code looking like this:: - - - -The number ``XXXXXXX`` is your account number. Set -:const:`OPTIMIZELY_ACCOUNT_NUMBER` in the project :file:`settings.py` -file:: - - OPTIMIZELY_ACCOUNT_NUMBER = 'XXXXXXX' - -If you do not set an account number, the Javascript code will not be -rendered. - - -.. _optimizely-internal-ips: - -Internal IP addresses ---------------------- - -Usually you do not want to use A/B testing on your development or -internal IP addresses. By default, if the tags detect that the client -comes from any address in the :const:`INTERNAL_IPS` setting, the -tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` -for important information about detecting the visitor IP address. -""" - -optimizely_service = { - 'head_top': 'analytical.optimizely.templatetags.optimizely.OptimizelyNode', -} diff --git a/analytical/optimizely/templatetags/__init__.py b/analytical/optimizely/templatetags/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/analytical/templatetags/analytical.py b/analytical/templatetags/analytical.py index 024d655..7a0e99b 100644 --- a/analytical/templatetags/analytical.py +++ b/analytical/templatetags/analytical.py @@ -12,15 +12,15 @@ from django.utils.importlib import import_module DEFAULT_SERVICES = [ - 'analytical.chartbeat.chartbeat_service', - 'analytical.clicky.clicky_service', - 'analytical.crazy_egg.crazy_egg_service', - 'analytical.google_analytics.google_analytics_service', - 'analytical.hubspot.hubspot_service', - 'analytical.kiss_insights.kiss_insights_service', - 'analytical.kiss_metrics.kiss_metrics_service', - 'analytical.mixpanel.MixpanelService', - 'analytical.optimizely.OptimizelyService', + 'analytical.templatetags.chartbeat.service', + 'analytical.templatetags.clicky.service', + 'analytical.templatetags.crazy_egg.service', + 'analytical.templatetags.google_analytics.service', + 'analytical.templatetags.hubspot.service', + 'analytical.templatetags.kiss_insights.service', + 'analytical.templatetags.kiss_metrics.service', + 'analytical.templatetags.mixpanel.service', + 'analytical.templatetags.optimizely.service', ] LOCATIONS = ['head_top', 'head_bottom', 'body_top', 'body_bottom'] @@ -50,33 +50,64 @@ class AnalyticalNode(Node): def _load_template_nodes(): - location_nodes = dict((loc, []) for loc in LOCATIONS) try: service_paths = settings.ANALYTICAL_SERVICES autoload = False except AttributeError: service_paths = DEFAULT_SERVICES autoload = True - for path in service_paths: + services = _get_services(service_paths) + location_nodes = dict((loc, []) for loc in LOCATIONS) + for location in LOCATIONS: + node_tuples = [] + for service in services: + node_tuple = service.get(location) + if node_tuple is not None: + if not isinstance(node_tuple, tuple): + node_tuple = (node_tuple, None) + node_tuples[location].append(node_tuple) + location_nodes[location] = _get_nodes(node_tuples, autoload) + return location_nodes + +def _get_nodes(node_tuples, autoload): + nodes = [] + node_sort_key = lambda n: {'first': -1, None: 0, 'last': 1}[n[1]] + for node_tuple in sorted(node_tuples, key=node_sort_key): + node_cls = node_tuple[0] try: - service = _import_path(path) - for location in LOCATIONS: - node_path = service.get(location) - if node_path is not None: - node_cls = _import_path(node_path) - node = node_cls() - location_nodes[location].append(node) + nodes.append(node_cls()) except ImproperlyConfigured, e: if autoload: _log.debug("not loading analytical service '%s': %s", - path, e) + node_cls.__module__, e) + continue else: raise - return location_nodes + return nodes -def _import_path(path): - mod_name, attr_name = path.rsplit('.', 1) - mod = import_module(mod_name) - return getattr(mod, attr_name) +def _get_services(paths, autoload): + services = [] + for path in paths: + mod_name, attr_name = path.rsplit('.', 1) + try: + mod = import_module(mod_name) + except ImportError, e: + if autoload: + _log.exception(e) + continue + else: + raise + try: + service = getattr(mod, attr_name) + except AttributeError, e: + if autoload: + _log.debug("not loading analytical service '%s': " + "module '%s' does not provide attribute '%s'", + path, mod_name, attr_name) + continue + else: + raise + services.append(service) + return services template_nodes = _load_template_nodes() diff --git a/analytical/chartbeat/templatetags/chartbeat.py b/analytical/templatetags/chartbeat.py similarity index 94% rename from analytical/chartbeat/templatetags/chartbeat.py rename to analytical/templatetags/chartbeat.py index cee59a2..f28df71 100644 --- a/analytical/chartbeat/templatetags/chartbeat.py +++ b/analytical/templatetags/chartbeat.py @@ -1,7 +1,9 @@ """ -Chartbeat template tags. +Chartbeat template tags and filters. """ +from __future__ import absolute_import + import re from django.conf import settings @@ -94,3 +96,9 @@ class ChartbeatBottomNode(Node): if is_internal_ip(context): html = disable_html(html, 'Chartbeat') return html + + +service = { + 'head_top': (ChartbeatTopNode, 'first'), + 'body_bottom': (ChartbeatBottomNode, 'last'), +} diff --git a/analytical/clicky/templatetags/clicky.py b/analytical/templatetags/clicky.py similarity index 94% rename from analytical/clicky/templatetags/clicky.py rename to analytical/templatetags/clicky.py index e2bca76..cd0b969 100644 --- a/analytical/clicky/templatetags/clicky.py +++ b/analytical/templatetags/clicky.py @@ -1,7 +1,9 @@ """ -Clicky template tags. +Clicky template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -66,3 +68,8 @@ class ClickyNode(Node): if is_internal_ip(context): html = disable_html(html, 'Clicky') return html + + +service = { + 'body_bottom': ClickyNode, +} diff --git a/analytical/crazy_egg/templatetags/crazy_egg.py b/analytical/templatetags/crazy_egg.py similarity index 93% rename from analytical/crazy_egg/templatetags/crazy_egg.py rename to analytical/templatetags/crazy_egg.py index a670f64..269fa86 100644 --- a/analytical/crazy_egg/templatetags/crazy_egg.py +++ b/analytical/templatetags/crazy_egg.py @@ -1,7 +1,9 @@ """ -Crazy Egg template tags. +Crazy Egg template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -50,3 +52,8 @@ class CrazyEggNode(Node): if is_internal_ip(context): html = disable_html(html, 'Crazy Egg') return html + + +service = { + 'body_bottom': CrazyEggNode, +} diff --git a/analytical/google_analytics/templatetags/google_analytics.py b/analytical/templatetags/google_analytics.py similarity index 92% rename from analytical/google_analytics/templatetags/google_analytics.py rename to analytical/templatetags/google_analytics.py index 45d1e25..c062ce7 100644 --- a/analytical/google_analytics/templatetags/google_analytics.py +++ b/analytical/templatetags/google_analytics.py @@ -1,14 +1,18 @@ """ -Google Analytics template tags. +Google Analytics template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError -from analytical.google_analytics import SCOPE_PAGE from analytical.utils import is_internal_ip, disable_html +SCOPE_VISITOR = 1 +SCOPE_SESSION = 2 +SCOPE_PAGE = 3 PROPERTY_ID_RE = re.compile(r'^UA-\d+-\d+$') SETUP_CODE = """ @@ -75,3 +79,8 @@ class GoogleAnalyticsNode(Node): scope = SCOPE_PAGE commands.append(CUSTOM_VAR_CODE % locals()) return commands + + +service = { + 'head_bottom': GoogleAnalyticsNode, +} diff --git a/analytical/hubspot/templatetags/hubspot.py b/analytical/templatetags/hubspot.py similarity index 92% rename from analytical/hubspot/templatetags/hubspot.py rename to analytical/templatetags/hubspot.py index 0b89847..8c1b0d9 100644 --- a/analytical/hubspot/templatetags/hubspot.py +++ b/analytical/templatetags/hubspot.py @@ -1,7 +1,9 @@ """ -HubSpot template tags. +HubSpot template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -51,3 +53,8 @@ class HubSpotNode(Node): if is_internal_ip(context): html = disable_html(html, 'HubSpot') return html + + +service = { + 'body_bottom': HubSpotNode, +} diff --git a/analytical/kiss_insights/templatetags/kiss_insights.py b/analytical/templatetags/kiss_insights.py similarity index 95% rename from analytical/kiss_insights/templatetags/kiss_insights.py rename to analytical/templatetags/kiss_insights.py index 79ecbb4..eafe1ac 100644 --- a/analytical/kiss_insights/templatetags/kiss_insights.py +++ b/analytical/templatetags/kiss_insights.py @@ -2,6 +2,8 @@ KISSinsights template tags. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -57,3 +59,8 @@ class KissInsightsNode(Node): html = SETUP_CODE % {'account_number': self.account_number, 'site_code': self.site_code, 'commands': " ".join(commands)} return html + + +service = { + 'body_top': KissInsightsNode, +} diff --git a/analytical/kiss_metrics/templatetags/kiss_metrics.py b/analytical/templatetags/kiss_metrics.py similarity index 96% rename from analytical/kiss_metrics/templatetags/kiss_metrics.py rename to analytical/templatetags/kiss_metrics.py index 3e5b7fe..e3a1c50 100644 --- a/analytical/kiss_metrics/templatetags/kiss_metrics.py +++ b/analytical/templatetags/kiss_metrics.py @@ -2,6 +2,8 @@ KISSmetrics template tags. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -72,3 +74,8 @@ class KissMetricsNode(Node): if is_internal_ip(context): html = disable_html(html, 'Mixpanel') return html + + +service = { + 'head_top': KissMetricsNode, +} diff --git a/analytical/mixpanel/templatetags/mixpanel.py b/analytical/templatetags/mixpanel.py similarity index 94% rename from analytical/mixpanel/templatetags/mixpanel.py rename to analytical/templatetags/mixpanel.py index abd1c40..89adc80 100644 --- a/analytical/mixpanel/templatetags/mixpanel.py +++ b/analytical/templatetags/mixpanel.py @@ -1,7 +1,9 @@ """ -Mixpanel template tags. +Mixpanel template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -65,3 +67,8 @@ class MixpanelNode(Node): if is_internal_ip(context): html = disable_html(html, 'Mixpanel') return html + + +service = { + 'head_bottom': MixpanelNode, +} diff --git a/analytical/optimizely/templatetags/optimizely.py b/analytical/templatetags/optimizely.py similarity index 90% rename from analytical/optimizely/templatetags/optimizely.py rename to analytical/templatetags/optimizely.py index ff09034..92f9566 100644 --- a/analytical/optimizely/templatetags/optimizely.py +++ b/analytical/templatetags/optimizely.py @@ -1,7 +1,9 @@ """ -Optimizely template tags. +Optimizely template tags and filters. """ +from __future__ import absolute_import + import re from django.template import Library, Node, TemplateSyntaxError @@ -41,3 +43,8 @@ class OptimizelyNode(Node): if is_internal_ip(context): html = disable_html(html, 'Optimizely') return html + + +service = { + 'head_top': OptimizelyNode, +} diff --git a/docs/services/chartbeat.rst b/docs/services/chartbeat.rst index 6dd15b0..5558e3f 100644 --- a/docs/services/chartbeat.rst +++ b/docs/services/chartbeat.rst @@ -1,3 +1,132 @@ -.. currentmodule:: analytical.chartbeat +============================= +Chartbeat -- traffic analysis +============================= -.. automodule:: analytical.chartbeat +Chartbeat_ provides real-time analytics to websites and blogs. It shows +visitors, load times, and referring sites on a minute-by-minute basis. +The service also provides alerts the second your website crashes or +slows to a crawl. + +.. _Chartbeat: http://www.chartbeat.com/ + + +.. chartbeat-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`chartbeat-configuration`. + +In order to use the template tags, you need to add :mod:`analytical` +to the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The Chartbeat tracking code is inserted into templates using template +tags. At the top of the template, load the :mod:`chartbeat` template +tag library. Then insert the :ttag:`chartbeat_top` tag at the top of +the head section, and the :ttag:`chartbeat_bottom` tag at the bottom of +the body section:: + + {% load chartbeat %} + + + {% chartbeat_top %} + + ... + + {% chartbeat_bottom %} + + + +Because these tags are used to measure page loading time, it is +important to place them as close as possible to the start and end of the +document. + +.. _chartbeat-configuration: + +Configuration +============= + +Before you can use the Chartbeat integration, you must first set your +User ID. + + +.. _chartbeat-user-id: + +Setting the User ID +------------------- + +Your Chartbeat account has a unique User ID. You can find your User ID +by visiting the Chartbeat `Add New Site`_ page. The second code snippet +contains a line that looks like this:: + + var _sf_async_config={uid:XXXXX,domain:"YYYYYYYYYY"}; + +Here, ``XXXXX`` is your User ID. Set :const:`CHARTBEAT_USER_ID` in the +project :file:`settings.py` file:: + + CHARTBEAT_SITE_ID = 'XXXXX' + +If you do not set a User ID, the tracking code will not be rendered. + +.. _`Add New Site`: http://chartbeat.com/code/ + + +.. _chartbeat-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _chartbeat-domain: + +Setting the domain +------------------ + +The Javascript tracking code can send the website domain to Chartbeat. +If you use multiple subdomains this enables you to treat them as one +website in Chartbeat. If your project uses the sites framework, the +domain name of the current :class:`~django.contrib.sites.models.Site` +will be passed to Chartbeat automatically. You can modify this behavior +using the :const:`CHARTBEAT_AUTO_DOMAIN` setting:: + + CHARTBEAT_AUTO_DOMAIN = False + +Alternatively, you set the domain through the ``chartbeat_domain`` +context variable when you render the template:: + + context = RequestContext({'chartbeat_domain': 'example.com'}) + return some_template.render(context) + +It is annoying to do this for every view, so you may want to set it in +a context processor that you add to the +:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def chartbeat(request): + return {'chartbeat_domain': 'example.com'} + +The context domain overrides the domain from the current site. If no +domain is set, either explicitly or implicitly through the sites +framework, then no domain is sent, and Chartbeat will detect the domain +name from the URL. If your website uses just one domain, this will work +just fine. + + +---- + +Thanks go to Chartbeat for their support with the development of this +application. diff --git a/docs/services/clicky.rst b/docs/services/clicky.rst index dc20e31..b2d56ca 100644 --- a/docs/services/clicky.rst +++ b/docs/services/clicky.rst @@ -1,3 +1,145 @@ -.. currentmodule:: analytical.clicky +========================== +Clicky -- traffic analysis +========================== -.. automodule:: analytical.clicky +Clicky_ is an online web analytics tool. It is similar to Google +Analytics in that it provides statistics on who is visiting your website +and what they are doing. Clicky provides its data in real time and is +designed to be very easy to use. + +.. _Clicky: http://getclicky.com/ + + +.. clicky-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`clicky-configuration`. + +In order to use the template tag, you need to add +:mod:`analytical` to the installed applications list in the +project :file:`settings.py` file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The Clicky tracking code is inserted into templates using a template +tag. Load the :mod:`clicky` template tag library and insert the +:ttag:`clicky` tag. Because every page that you want to track must +have the tag, it is useful to add it to your base template. Insert +the tag at the bottom of the HTML body:: + + {% load clicky %} + ... + {% clicky %} + + + + +.. _clicky-configuration: + +Configuration +============= + +Before you can use the Clicky integration, you must first set your +website Site ID. You can also customize the data that Clicky tracks. + + +.. _clicky-site-id: + +Setting the Site ID +------------------- + +Every website you track with Clicky gets its own Site ID, and the +:ttag:`clicky` tag will include it in the rendered Javascript code. +You can find the Site ID in the *Info* tab of the website *Preferences* +page, in your Clicky account. Set :const:`CLICKY_SITE_ID` in the +project :file:`settings.py` file:: + + CLICKY_SITE_ID = 'XXXXXXXX' + +If you do not set a Site ID, the tracking code will not be rendered. + + +.. _clicky-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _clicky-custom-data: + +Custom data +----------- + +As described in the Clicky `customized tracking`_ documentation page, +the data that is tracked by Clicky can be customized by setting the +:data:`clicky_custom` Javascript variable before loading the tracking +code. Using template context variables, you can let the :ttag:`clicky` +tag pass custom data to Clicky automatically. You can set the context +variables in your view when your render a template containing the +tracking code:: + + context = RequestContext({'clicky_title': 'A better page title'}) + return some_template.render(context) + +It is annoying to do this for every view, so you may want to set custom +properties in a context processor that you add to the +:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def clicky_global_properties(request): + return {'clicky_timeout': 10} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. + +Here is a table with the most important variables. All variable listed +on the `customized tracking`_ documentation page can be set by replacing +``clicky_custom.`` with ``clicky_``. + +================== =============== =================================== +Context variable Clicky property Description +================== =============== =================================== +``clicky_session`` session_ Session data. A dictionary + containing ``username`` and/or + ``group`` keys. +------------------ --------------- ----------------------------------- +``clicky_goal`` goal_ A succeeded goal. A dictionary + containing ``id`` and ``revenue`` + keys. +------------------ --------------- ----------------------------------- +``clicky_href`` href_ The URL as tracked by Clicky. + Default is the page URL. +------------------ --------------- ----------------------------------- +``clicky_title`` title_ The page title as tracked by + Clicky. Default is the HTML title. +================== =============== =================================== + +By default, the username of an authenticated user is passed to Clicky +automatically in the session_ property, unless that property was set +explicitly. See :data:`ANALYTICAL_AUTO_IDENTIFY`. + +.. _`customized tracking`: http://getclicky.com/help/customization +.. _session: http://getclicky.com/help/customization#session +.. _goal: http://getclicky.com/help/customization#goal +.. _href: http://getclicky.com/help/customization#href +.. _title: http://getclicky.com/help/customization#title + + +---- + +Thanks go to Clicky for their support with the development of this +application. diff --git a/docs/services/crazy_egg.rst b/docs/services/crazy_egg.rst index b71b955..5ebadca 100644 --- a/docs/services/crazy_egg.rst +++ b/docs/services/crazy_egg.rst @@ -1,3 +1,121 @@ -.. currentmodule:: analytical.crazy_egg +================================== +Crazy Egg -- visual click tracking +================================== -.. automodule:: analytical.crazy_egg +`Crazy Egg`_ is an easy to use hosted web application that visualizes +website clicks using heatmaps. It allows you to discover the areas of +web pages that are most important to your visitors. + +.. _`Crazy Egg`: http://www.crazyegg.com/ + + +.. crazy-egg-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`crazy-egg-configuration`. + +In order to use the template tag, you need to add :mod:`analytical` to +the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The Crazy Egg tracking code is inserted into templates using a template +tag. Load the :mod:`crazy_egg` template tag library and insert the +:ttag:`crazy_egg` tag. Because every page that you want to track must +have the tag, it is useful to add it to your base template. Insert +the tag at the bottom of the HTML body:: + + {% load crazy_egg %} + ... + {% crazy_egg %} + + + + +.. _crazy-egg-configuration: + +Configuration +============= + +Before you can use the Crazy Egg integration, you must first set your +account number. You can also segment the click analysis through user +variables. + + +.. _crazy-egg-account-number: + +Setting the account number +-------------------------- + +Crazy Egg gives you a unique account number, and the :ttag:`crazy egg` +tag will include it in the rendered Javascript code. You can find your +account number by clicking the link named "What's my code?" in the +dashboard of your Crazy Egg account. Set +:const:`CRAZY_EGG_ACCOUNT_NUMBER` in the project :file:`settings.py` +file:: + + CRAZY_EGG_ACCOUNT_NUMBER = 'XXXXXXXX' + +If you do not set an account number, the tracking code will not be +rendered. + + +.. _crazy-egg-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _crazy-egg-uservars: + +User variables +-------------- + +Crazy Egg can segment clicks based on `user variables`_. If you want to +set a user variable, use the context variables ``crazy_egg_var1`` +through ``crazy_egg_var5`` when you render your template:: + + context = RequestContext({'crazy_egg_var1': 'red', + 'crazy_egg_var2': 'male'}) + return some_template.render(context) + +If you use the same user variables in different views and its value can +be computed from the HTTP request, you can also set them in a context +processor that you add to the :data:`TEMPLATE_CONTEXT_PROCESSORS` list +in :file:`settings.py`:: + + def segment_on_ip_proto(request): + addr = request.META.get('HTTP_X_FORWARDED_FOR', + request.META.get('REMOTE_ADDR', '')) + proto = 'ipv6' if ':' in addr else 'ipv4' + return {'crazy_egg_var3': proto} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. + +.. _`user variables`: https://www.crazyegg.com/help/Setting_Up_A_Page_to_Track/How_do_I_set_the_values_of_User_Var_1_User_Var_2_etc_in_the_confetti_and_overlay_views/ + + +---- + +The work on Crazy Egg was made possible by `Bateau Knowledge`_. Thanks +go to Crazy Egg for their support with the development of this +application. + +.. _`Bateau Knowledge`: http://www.bateauknowledge.nl/ diff --git a/docs/services/google_analytics.rst b/docs/services/google_analytics.rst index 0c847fd..5b887bc 100644 --- a/docs/services/google_analytics.rst +++ b/docs/services/google_analytics.rst @@ -1,3 +1,130 @@ -.. currentmodule:: analytical.google_analytics +==================================== +Google Analytics -- traffic analysis +==================================== -.. automodule:: analytical.google_analytics +`Google Analytics`_ is the well-known web analytics service from +Google. The product is aimed more at marketers than webmasters or +technologists, supporting integration with AdWords and other e-commence +features. + +.. _`Google Analytics`: http://www.google.com/analytics/ + + +.. google-analytics-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`google-analytics-configuration`. + +In order to use the template tag, you need to add :mod:`analytical` to +the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The Google Analytics tracking code is inserted into templates using a +template tag. Load the :mod:`google_analytics` template tag library and +insert the :ttag:`google_analytics` tag. Because every page that you +want to track must have the tag, it is useful to add it to your base +template. Insert the tag at the bottom of the HTML head:: + + {% load google_analytics %} + + + ... + {% google_analytics %} + + ... + + +.. _google-analytics-configuration: + +Configuration +============= + +Before you can use the Google Analytics integration, you must first set +your website property ID. You can also add custom segments for Google +Analytics to track. + + +.. _google-analytics-property-id: + +Setting the property ID +----------------------- + +Every website you track with Google Analytics gets its own property ID, +and the :ttag:`google_analytics` tag will include it in the rendered +Javascript code. You can find the web property ID on the overview page +of your account. Set :const:`GOOGLE_ANALYTICS_PROPERTY_ID` in the +project :file:`settings.py` file:: + + GOOGLE_ANALYTICS_PROPERTY_ID = 'UA-XXXXXX-X' + +If you do not set a property ID, the tracking code will not be rendered. + + +.. _google-analytics-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _google-analytics-custom-variables: + +Custom variables +---------------- + +As described in the Google Analytics `custom variables`_ documentation +page, you can define custom segments. Using template context variables +``google_analytics_var1`` through ``google_analytics_var5``, you can let +the :ttag:`google_analytics` tag pass custom variables to Google +Analytics automatically. You can set the context variables in your view +when your render a template containing the tracking code:: + + context = RequestContext({'google_analytics_var1': ('gender', 'female'), + 'google_analytics_var2': ('visit', '1', SCOPE_SESSION)}) + return some_template.render(context) + +The value of the context variable is a tuple *(name, value, [scope])*. +The scope parameter is one of the +:const:`analytical.google_analytics.SCOPE_*` constants: + +================= ====== ============================================= +Constant Value Description +================= ====== ============================================= +``SCOPE_VISITOR`` 1 Distinguishes categories of visitors across + multiple sessions. +``SCOPE_SESSION`` 2 Ddistinguishes different visitor experiences + across sessions. +``SCOPE_PAGE`` 3 Defines page-level activity. +================= ====== ============================================= + +The default scope is :const:`~analytical.google_analytics.SCOPE_PAGE`. + +You may want to set custom variables in a context processor that you add +to the :data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def google_analytics_segment_language(request): + try: + return {'google_analytics_var3': request.LANGUAGE_CODE} + except AttributeError: + return {} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. + +.. _`custom variables`: http://code.google.com/apis/analytics/docs/tracking/gaTrackingCustomVariables.html diff --git a/analytical/hubspot/__init__.py b/docs/services/hubspot.rst similarity index 88% rename from analytical/hubspot/__init__.py rename to docs/services/hubspot.rst index f14eb45..c63afe2 100644 --- a/analytical/hubspot/__init__.py +++ b/docs/services/hubspot.rst @@ -1,4 +1,3 @@ -""" ============================ HubSpot -- inbound marketing ============================ @@ -19,13 +18,13 @@ You only need to do perform these steps if you are not using the generic :ttag:`analytical.*` tags. If you are, skip to :ref:`hubspot-configuration`. -In order to use the template tag, you need to add -:mod:`analytical.hubspot` to the installed applications list in the -project :file:`settings.py` file:: +In order to use the template tag, you need to add :mod:`analytical` to +the installed applications list in the project :file:`settings.py` +file:: INSTALLED_APPS = [ ... - 'analytical.hubspot', + 'analytical', ... ] @@ -81,8 +80,3 @@ internal IP addresses. By default, if the tags detect that the client comes from any address in the :const:`INTERNAL_IPS` setting, the tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` for important information about detecting the visitor IP address. -""" - -hubspot_service = { - 'body_bottom': 'analytical.hubspot.templatetags.hupspot.HubSpotNode', -} diff --git a/docs/services/kiss_insights.rst b/docs/services/kiss_insights.rst index 9f2e105..1ef9aa5 100644 --- a/docs/services/kiss_insights.rst +++ b/docs/services/kiss_insights.rst @@ -1,3 +1,127 @@ -.. currentmodule:: analytical.kiss_insights +================================ +KISSinsights -- feedback surveys +================================ -.. automodule:: analytical.kiss_insights +KISSinsights_ provides unobtrusive surveys that pop up from the bottom +right-hand corner of your website. Asking specific questions gets you +the targeted, actionable feedback you need to make your site better. + +.. _KISSinsights: http://www.kissinsights.com/ + + +.. kiss-insights-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`kiss-insights-configuration`. + +In order to use the template tag, you need to add :mod:`analytical` to +the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The KISSinsights survey code is inserted into templates using a template +tag. Load the :mod:`kiss_insights` template tag library and insert the +:ttag:`kiss_insights` tag. Because every page that you want to track +must have the tag, it is useful to add it to your base template. Insert +the tag at the bottom of the HTML body:: + + {% load kiss_insights %} + ... + + + {% kiss_insights %} + ... + + +.. _kiss-insights-configuration: + +Configuration +============= + +Before you can use the KISSinsights integration, you must first set your +account number and site code. + + +.. _kiss-insights-account-number: + +Setting the account number and site code +---------------------------------------- + +In order to install the survey code, you need to set your KISSinsights +account number and website code. The :ttag:`kiss_insights` tag will +include it in the rendered Javascript code. You can find the account +number and website code by visiting the code installation page of the +website you want to place the surveys on. You will see some HTML code +with a Javascript tag with a ``src`` attribute containing +``//s3.amazonaws.com/ki.js/XXXXX/YYY.js``. Here ``XXXXX`` is the +account number and ``YYY`` the website code. Set +:const:`KISS_INSIGHTS_ACCOUNT_NUMBER` and +:const:`KISS_INSIGHTS_WEBSITE_CODE` in the project :file:`settings.py` +file:: + + KISSINSIGHTS_ACCOUNT_NUMBER = 'XXXXX' + KISSINSIGHTS_SITE_CODE = 'XXX' + +If you do not set the account number and website code, the survey code +will not be rendered. + + +.. _kiss-insights-identity-user: + +Identifying authenticated users +------------------------------- + +If your websites identifies visitors, you can pass this information on +to KISSinsights so that you can tie survey submissions to customers. +By default, the username of an authenticated user is passed to +KISSinsights automatically. See :data:`ANALYTICAL_AUTO_IDENTIFY` for +important information about detecting authenticated visitors. + +You can also send the visitor identity yourself by adding the +``analytical_identity`` variable to the template context:: + + context = RequestContext({'analytical_identity': identity}) + return some_template.render(context) + +If you can derive the identity from the HTTP request, you can also use +a context processor that you add to the +:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def identify(request): + try: + return {'analytical_identity': request.user.email} + except AttributeError: + return {} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. + + +.. _kiss-insights-show-survey: + +Showing a specific survey +------------------------- + +KISSinsights can also be told to show a specific survey. You can let +the :ttag:`kiss_insights` tag include the code to select a survey by +passing the survey ID to the template in the +``kiss_insights_show_survey`` context variable:: + + context = RequestContext({'kiss_insights_show_survey': 1234}) + return some_template.render(context) + +For information about how to find the survey ID, see the explanation +on `"How can I show a survey after a custom trigger condition?"`_ on the +KISSinsights help page. + +.. _`"How can I show a survey after a custom trigger condition?"`: http://www.kissinsights.com/help#customer-trigger diff --git a/docs/services/kiss_metrics.rst b/docs/services/kiss_metrics.rst index f88d3d9..85232ab 100644 --- a/docs/services/kiss_metrics.rst +++ b/docs/services/kiss_metrics.rst @@ -1,3 +1,111 @@ -.. currentmodule:: analytical.kiss_metrics +============================== +KISSmetrics -- funnel analysis +============================== -.. automodule:: analytical.kiss_metrics +KISSmetrics_ is an easy to implement analytics solution that provides a +powerful visual representation of your customer lifecycle. Discover how +many visitors go from your landing page to pricing to sign up, and how +many drop out at each stage. + +.. _KISSmetrics: http://www.kissmetrics.com/ + + +.. kiss-metrics-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`kiss-metrics-configuration`. + +In order to use the template tag, you need to add :mod:`analytical` to +the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The KISSmetrics Javascript code is inserted into templates using a +template tag. Load the :mod:`kiss_metrics` template tag library and +insert the :ttag:`kiss_metrics` tag. Because every page that you want +to track must have the tag, it is useful to add it to your base +template. Insert the tag at the top of the HTML head:: + + {% load kiss_metrics %} + + + {% kiss_metrics %} + ... + + +.. _kiss-metrics-configuration: + +Configuration +============= + +Before you can use the KISSmetrics integration, you must first set your +API key. + + +.. _kiss-metrics-api-key: + +Setting the API key +------------------- + +Every website you track events for with KISSmetrics gets its own API +key, and the :ttag:`kiss_metrics` tag will include it in the rendered +Javascript code. You can find the website API key by visiting the +website *Product center* on your KISSmetrics dashboard. Set +:const:`KISS_METRICS_API_KEY` in the project :file:`settings.py` file:: + + KISS_METRICS_API_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' + +If you do not set an API key, the tracking code will not be rendered. + + +.. _kiss-metrics-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _kiss-metrics-identify-user: + +Identifying users +----------------- + +If your websites identifies visitors, you can pass this information on +to KISSmetrics so that you can tie events to users. By default, the +username of an authenticated user is passed to KISSmetrics +automatically. See :data:`ANALYTICAL_AUTO_IDENTIFY` for important +information about detecting authenticated visitors. + +You can also send the visitor identity yourself by adding the +``analytical_identity`` variable to the template context:: + + context = RequestContext({'analytical_identity': identity}) + return some_template.render(context) + +If you can derive the identity from the HTTP request, you can also use +a context processor that you add to the +:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def identify(request): + try: + return {'analytical_identity': request.user.email} + except AttributeError: + return {} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. diff --git a/docs/services/mixpanel.rst b/docs/services/mixpanel.rst index d8c4af9..275c73d 100644 --- a/docs/services/mixpanel.rst +++ b/docs/services/mixpanel.rst @@ -1,3 +1,110 @@ -.. currentmodule:: analytical.mixpanel +========================== +Mixpanel -- event tracking +========================== -.. automodule:: analytical.mixpanel +Mixpanel_ tracks events and actions to see what features users are using +the most and how they are trending. You could use it for real-time +analysis of visitor retention or funnels. + +.. _Mixpanel: http://www.mixpanel.com/ + + +.. mixpanel-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`mixpanel-configuration`. + +In order to use the template tag, you need to add :mod:`analyticals` to +the installed applications list in the project :file:`settings.py` +file:: + + INSTALLED_APPS = [ + ... + 'analytical', + ... + ] + +The Mixpanel Javascript code is inserted into templates using a +template tag. Load the :mod:`mixpanel` template tag library and +insert the :ttag:`mixpanel` tag. Because every page that you want +to track must have the tag, it is useful to add it to your base +template. Insert the tag at the bottom of the HTML head:: + + {% load mixpanel %} + ... + {% mixpanel %} + + + ... + + +.. _mixpanel-configuration: + +Configuration +============= + +Before you can use the Mixpanel integration, you must first set your +token. + + +.. _mixpanel-api-key: + +Setting the token +----------------- + +Every website you track events for with Mixpanel gets its own token, +and the :ttag:`mixpanel` tag will include it in the rendered Javascript +code. You can find the project token on the Mixpanel *projects* page. +Set :const:`MIXPANEL_TOKEN` in the project :file:`settings.py` file:: + + MIXPANEL_TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' + +If you do not set a token, the tracking code will not be rendered. + + +.. _mixpanel-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to track clicks from your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address. + + +.. _mixpanel-identify-user: + +Identifying users +----------------- + +If your websites identifies visitors, you can pass this information on +to Mixpanel so that you can tie events to users. By default, the +username of an authenticated user is passed to Mixpanel automatically. +See :data:`ANALYTICAL_AUTO_IDENTIFY` for important information about +detecting authenticated visitors. + +You can also send the visitor identity yourself by adding the +``analytical_identity`` variable to the template context:: + + context = RequestContext({'analytical_identity': identity}) + return some_template.render(context) + +If you can derive the identity from the HTTP request, you can also use +a context processor that you add to the +:data:`TEMPLATE_CONTEXT_PROCESSORS` list in :file:`settings.py`:: + + def identify(request): + try: + return {'analytical_identity': request.user.email} + except AttributeError: + return {} + +Just remember that if you set the same context variable in the +:class:`~django.template.context.RequestContext` constructor and in a +context processor, the latter clobbers the former. diff --git a/docs/services/optimizely.rst b/docs/services/optimizely.rst index b0af136..e96043a 100644 --- a/docs/services/optimizely.rst +++ b/docs/services/optimizely.rst @@ -1,3 +1,86 @@ -.. currentmodule:: analytical.optimizely +========================= +Optimizely -- A/B testing +========================= -.. automodule:: analytical.optimizely +Optimizely_ is an easy way to implement A/B testing. Try different +decisions, images, layouts, and copy without touching your website code +and see exactly how your experiments are affecting pageviews, +retention and sales. + +.. _Optimizely: http://www.optimizely.com/ + + +.. optimizely-installation: + +Installation +============ + +You only need to do perform these steps if you are not using the +generic :ttag:`analytical.*` tags. If you are, skip to +:ref:`optimizely-configuration`. + +In order to use the template tag, you need to add +:mod:`analytical.optimizely` to the installed applications list in the +project :file:`settings.py` file:: + + INSTALLED_APPS = [ + ... + 'analytical.optimizely', + ... + ] + +The Optimizely Javascript code is inserted into templates using a +template tag. Load the :mod:`mixpanel` template tag library and insert +the :ttag:`optimizely` tag. Because every page that you want to track +must have the tag, it is useful to add it to your base template. +Insert the tag at the top of the HTML head:: + + {% load optimizely %} + + + {% optimizely %} + ... + + +.. _optimizely-configuration: + +Configuration +============= + +Before you can use the Optimizely integration, you must first set your +account number. + + +.. _optimizely-account-number: + +Setting the account number +-------------------------- + +Optimizely gives you a unique account number, and the :ttag:`optimizely` +tag will include it in the rendered Javascript code. You can find your +account number by clicking the `Implementation` link in the top +right-hand corner of the Optimizely website. A pop-up window will +appear containing HTML code looking like this:: + + + +The number ``XXXXXXX`` is your account number. Set +:const:`OPTIMIZELY_ACCOUNT_NUMBER` in the project :file:`settings.py` +file:: + + OPTIMIZELY_ACCOUNT_NUMBER = 'XXXXXXX' + +If you do not set an account number, the Javascript code will not be +rendered. + + +.. _optimizely-internal-ips: + +Internal IP addresses +--------------------- + +Usually you do not want to use A/B testing on your development or +internal IP addresses. By default, if the tags detect that the client +comes from any address in the :const:`INTERNAL_IPS` setting, the +tracking code is commented out. See :const:`ANALYTICAL_INTERNAL_IPS` +for important information about detecting the visitor IP address.