diff --git a/README.md b/README.md
index 550bc9a..6f83020 100644
--- a/README.md
+++ b/README.md
@@ -84,6 +84,13 @@ or
{% tawkto_script id_site='tawktosideit' api_key='tawktoapikey'%}
```
+(Optional) If you want to hide the chat for superuser (default is `True`):
+
+```python
+TAWKTO_EXCLUDE_SUPERUSERS = True
+```
+
+
(Optional) Set custom metadata regarding this chat/visitor:
- `is_secure` must be `True`.
diff --git a/tawkto/templates/tawkto/templatetags/_script.html b/tawkto/templates/tawkto/templatetags/_script.html
new file mode 100644
index 0000000..3a7b83c
--- /dev/null
+++ b/tawkto/templates/tawkto/templatetags/_script.html
@@ -0,0 +1,32 @@
+
+{{ tawkto_data|json_script:"tawkto_data" }}
+
+
diff --git a/tawkto/templates/tawkto/templatetags/tawkto_script.html b/tawkto/templates/tawkto/templatetags/tawkto_script.html
index 3a7b83c..231487a 100644
--- a/tawkto/templates/tawkto/templatetags/tawkto_script.html
+++ b/tawkto/templates/tawkto/templatetags/tawkto_script.html
@@ -1,32 +1,3 @@
-
-{{ tawkto_data|json_script:"tawkto_data" }}
-
-
+{% if not exclude_superusers %}
+ {% include 'tawkto/templatetags/_script.html' with tawkto_data=tawkto_data only %}
+{% endif %}
diff --git a/tawkto/templatetags/tawkto_tags.py b/tawkto/templatetags/tawkto_tags.py
index 646b8b1..cf23bc9 100644
--- a/tawkto/templatetags/tawkto_tags.py
+++ b/tawkto/templatetags/tawkto_tags.py
@@ -13,6 +13,7 @@ def tawkto_script(**kwargs):
default_api_key = getattr(settings, "TAWKTO_API_KEY", None)
default_widget_id = getattr(settings, "TAWKTO_WIDGET_ID", "default")
default_is_secure = getattr(settings, "TAWKTO_IS_SECURE", False)
+ exclude_superusers = getattr(settings, "TAWKTO_EXCLUDE_SUPERUSERS", True)
user_email = kwargs.get("user_email", "")
user_name = kwargs.get("user_name", "")
@@ -43,4 +44,7 @@ def tawkto_script(**kwargs):
).hexdigest()
data["visitor"]["hash"] = hash_hmac
- return {"tawkto_data": data}
+ return {
+ "tawkto_data": data,
+ "exclude_superusers": exclude_superusers,
+ }
diff --git a/test_project/test_project/settings.py b/test_project/test_project/settings.py
index e2e462d..7114394 100644
--- a/test_project/test_project/settings.py
+++ b/test_project/test_project/settings.py
@@ -129,3 +129,4 @@
TAWKTO_API_KEY = os.environ.get("TAWKTO_API_KEY", "")
TAWKTO_WIDGET_ID = os.environ.get("TAWKTO_WIDGET_ID", "")
TAWKTO_IS_SECURE = True
+TAWKTO_EXCLUDE_SUPERUSERS = False
diff --git a/test_project/test_project/urls.py b/test_project/test_project/urls.py
index a145ce6..d0b8474 100644
--- a/test_project/test_project/urls.py
+++ b/test_project/test_project/urls.py
@@ -1,7 +1,8 @@
-from django.urls import path
-
from app.views import test_view
+from django.contrib import admin
+from django.urls import path
urlpatterns = [
+ path("admin/", admin.site.urls),
path("", test_view),
]