2013-03-24 23:25:17 +00:00
..
After updating this file, remember to upload to the UserVoice
knowledge base.
2012-02-08 01:16:18 +00:00
=======================================
UserVoice -- user feedback and helpdesk
=======================================
UserVoice_ makes it simple for your customers to give, discuss, and vote
2012-02-27 00:15:33 +00:00
for feedback. An unobtrusive feedback tab allows visitors to easily
2012-02-08 01:16:18 +00:00
submit and discuss ideas without having to sign up for a new account.
The best ideas are delivered to you based on customer votes.
.. _UserVoice: http://www.uservoice.com/
2012-02-27 00:15:33 +00:00
.. _uservoice-installation:
2012-02-08 01:16:18 +00:00
Installation
============
To start using the UserVoice integration, you must have installed the
django-analytical package and have added the `` analytical `` application
to :const: `INSTALLED_APPS` in your project :file: `settings.py` file.
See :doc: `../install` for details.
Next you need to add the UserVoice template tag to your templates.
This step is only needed if you are not using the generic
:ttag: `analytical.*` tags. If you are, skip to
:ref: `uservoice-configuration` .
The UserVoice Javascript code is inserted into templates using a
template tag. Load the :mod: `uservoice` template tag library and insert
the :ttag: `uservoice` tag. Because every page that you want to have
2012-02-27 00:15:33 +00:00
the feedback tab to appear on must have the tag, it is useful to add
2012-02-08 01:16:18 +00:00
it to your base template. Insert the tag at the bottom of the HTML
body::
{% load uservoice %}
...
{% uservoice %}
</body>
</html>
.. _uservoice-configuration:
Configuration
=============
2012-02-27 00:15:33 +00:00
Before you can use the UserVoice integration, you must first set the
widget key.
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
Setting the widget key
----------------------
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
In order to use the feedback widget, you need to configure which widget
you want to show. You can find the widget keys in the *Channels* tab on
your UserVoice *Settings* page. Under the *Javascript Widget* heading,
find the Javascript embed code of the widget. The widget key is the
alphanumerical string contained in the URL of the script imported by the
embed code::
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
<script type="text/javascript">
2013-11-26 15:44:05 +00:00
UserVoice=window.UserVoice||[];(function(){
var uv=document.createElement('script');uv.type='text/javascript';
uv.async=true;uv.src='//widget.uservoice.com/XXXXXXXXXXXXXXXXXXXX.js';
var s=document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(uv,s)})();
2012-02-27 00:15:33 +00:00
</script>
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
(The widget key is shown as `` XXXXXXXXXXXXXXXXXXXX `` .)
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
The default widget
..................
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
Often you will use the same widget throughout your website. The default
widget key is configured by setting :const: `USERVOICE_WIDGET_KEY` in
the project :file: `settings.py` file::
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
USERVOICE_WIDGET_KEY = 'XXXXXXXXXXXXXXXXXXXX'
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
If the setting is present but empty, no widget is shown by default. This
is useful if you want to set a widget using a template context variable,
as the setting must be present for the generic :ttag: `analytical.*` tags
to work.
2012-02-08 01:16:18 +00:00
2013-11-26 15:44:05 +00:00
Widget options
..............
You can set :const: `USERVOICE_WIDGET_OPTIONS` to customize your widget
with UserVoice's options.
.. tip ::
See the `JS SDK Overview <https://developer.uservoice.com/docs/widgets/overview/> `_ and the `reference <https://developer.uservoice.com/docs/widgets/options/> `_ for the details of available options.
For example, to override the default position of the widget, you could define:
.. code-block :: python
USERVOICE_WIDGET_OPTIONS = (('addTrigger',
{"trigger_position": "bottom-left",
"mode": "contact"}),)
2012-02-27 00:15:33 +00:00
Per-view widget
...............
2012-02-08 01:16:18 +00:00
2013-11-26 15:44:05 +00:00
The widget key can be set in a view using the `` uservoice_widget_key `` and
`` uservoice_widget_options `` template context variables::
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
context = RequestContext({'uservoice_widget_key': 'XXXXXXXXXXXXXXXXXXXX'})
2012-02-08 01:16:18 +00:00
return some_template.render(context)
2013-11-26 15:44:05 +00:00
These variable passed in the context overrides the default
widget configuration.
2012-02-27 00:15:33 +00:00
Setting the widget key in a context processor
.............................................
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
You can also set the widget keys in a context processor that you add to
the :data: `TEMPLATE_CONTEXT_PROCESSORS` list in :file: `settings.py` .
For example, to show a specific widget to logged in users::
def uservoice_widget_key(request):
2012-02-08 01:16:18 +00:00
try:
2012-02-27 00:15:33 +00:00
if request.user.is_authenticated():
return {'uservoice_widget_key': 'XXXXXXXXXXXXXXXXXXXX'}
2012-02-08 01:16:18 +00:00
except AttributeError:
2012-02-27 00:15:33 +00:00
pass
return {}
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
The widget key passed in the context variable overrides both the default
and the per-view widget key.
2012-02-08 01:16:18 +00:00
2012-02-27 00:15:33 +00:00
In this case, the default widget tab is not hidden.
2012-02-08 01:16:18 +00:00
----
Thanks go to UserVoice for their support with the development of this
application.