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.
2013-11-26 16:55:46 +00:00
For example, to override the default icon style with a tab and on the left,
you could define:
2013-11-26 15:44:05 +00:00
.. code-block :: python
2013-11-26 16:55:46 +00:00
USERVOICE_WIDGET_OPTIONS = {"trigger_position": "left",
"trigger_style": "tab"}
2013-11-26 15:44:05 +00:00
2012-02-27 00:15:33 +00:00
Per-view widget
...............
2012-02-08 01:16:18 +00:00
2013-11-26 16:55:46 +00:00
The widget configuration can be overriden in a view using
`` uservoice_widget_options `` template context variable. For example:
.. code-block :: python
context = RequestContext({'uservoice_widget_options': 'mode': 'satisfaction'})
return some_template.render(context)
It's also possible to set a different widget key for a particular view
with `` uservoice_widget_key `` :
.. code-block :: python
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
2013-11-26 17:15:29 +00:00
.. _uservoice-link:
Using a custom link
-------------------
Instead of showing the default feedback icon or tab, you can make the UserVoice
widget launch when a visitor clicks a link or when some other event
occurs. As the `documentation describe <https://developer.uservoice.com/docs/widgets/methods/#custom-trigger> `_ , simply add the `` data-uv-trigger `` HTML attribute to the element. For example::
2013-11-26 17:16:47 +00:00
<a href="mailto:questions@yoursite.com" data-uv-trigger>Contact us</a>
2013-11-26 17:15:29 +00:00
In order to hidden the default trigger, you should disable it putting
2013-11-26 17:16:47 +00:00
`` uservoice_add_trigger `` to `` False `` ::
2013-11-26 17:15:29 +00:00
context = RequestContext({'uservoice_add_trigger': False})
return your_template_with_custom_uservoice_link.render(context)
If you want to disable the automatic trigger globally, set in :file: `settings.py` ::
USERVOICE_ADD_TRIGGER = False
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
2014-08-26 01:33:53 +00:00
Identifying users
-----------------
If your websites identifies visitors, you can pass this information on
2015-03-09 19:38:48 +00:00
to Uservoice. By default, the name and email of an authenticated user
is passed to Uservoice automatically. See :ref: `identifying-visitors` .
2014-08-26 01:33:53 +00:00
You can also send the visitor identity yourself by adding either the
`` uservoice_identity `` or the `` analytical_identity `` variable to
2015-03-09 19:38:48 +00:00
the template context. (If both are set, the former takes precedence.)
This should be a dictionary with the desired user traits as its keys.
Check the `documentation on identifying users`_ to see valid traits.
For example::
2014-08-26 01:33:53 +00:00
context = RequestContext({'uservoice_identity': {'email': user_email,
'name': username }})
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 {'uservoice_identity': {
email: request.user.username,
name: request.user.get_full_name(),
id: request.user.id,
type: 'vip',
account: {
name: 'Acme, Co.',
monthly_rate: 9.99,
ltv: 1495.00,
plan: 'Enhanced'
}
}
}
except AttributeError:
return {}
2012-02-08 01:16:18 +00:00
2015-03-09 19:38:48 +00:00
.. _`documentation on identifying users`: https://developer.uservoice.com/docs/widgets/identify/
2012-02-08 01:16:18 +00:00
----
Thanks go to UserVoice for their support with the development of this
application.