Google Tag Manager Installation
Add Simple Commenter to your website using Google Tag Manager (GTM). This method uses the data attribute loading mode since GTM can modify query parameters in script URLs.
GTM sometimes strips or modifies URL query parameters. Using data-domain instead of a query parameter ensures your domain is always passed correctly.
Prerequisites
- A Google Tag Manager account
- GTM container installed on your website
- Your Simple Commenter domain from the dashboard
Step-by-Step Installation
1. Open Google Tag Manager
Go to tagmanager.google.com and select your container.
2. Create a New Tag
- Click Tags in the left sidebar
- Click New to create a new tag
- Name it "Simple Commenter Widget"
3. Configure the Tag
- Click Tag Configuration
- Select Custom HTML
- Paste this code:
<script
src="https://simplecommenter.com/js/comments.min.js"
data-domain="your-domain.com"
defer
></script>
Replace your-domain.com with your actual domain from the Simple Commenter dashboard.
4. Set the Trigger
- Click Triggering
- Select All Pages (or choose specific pages)
- Click Save
5. Publish
- Click Submit in the top right
- Add a version name (e.g., "Added Simple Commenter")
- Click Publish
Alternative: Function Call Method
If the script still doesn't load, use the function call method which dynamically injects the script:
<script type="text/javascript">
(function(k,s) {
s=document.createElement('script');
s.async=true;
s.src="https://simplecommenter.com/js/comments.min.js";
s.dataset.domain=k;
document.head.appendChild(s);
})('your-domain.com')
</script>
Using GTM Variables
You can use GTM variables to make the domain dynamic:
<script
src="https://simplecommenter.com/js/comments.min.js"
data-domain="{{Page Hostname}}"
defer
></script>
This uses GTM's built-in Page Hostname variable, which automatically uses the current page's hostname.
Verifying Installation
- Use GTM's Preview mode to test before publishing
- Open your website and check for the feedback widget
- Open Developer Tools (F12) and verify the script loaded in the Network tab
- Check the Console for any errors
Troubleshooting
Widget not appearing
- Ensure the GTM container is properly installed on your site
- Check that the tag is firing (use GTM Preview mode)
- Verify the domain matches your dashboard settings exactly
- Try the function call method above
Tag fires but widget doesn't load
- Check for Content Security Policy errors in the browser console
- Ensure no other scripts are conflicting
- Try triggering on
DOM Readyinstead ofAll Pages
Multiple widgets appearing
- Check you don't have the script added both via GTM and directly in your HTML
- Ensure the tag only fires once per page
Advanced: Conditional Loading
Load the widget only on specific pages using GTM triggers:
Example: Only on blog pages
- Create a new trigger
- Set type to Page View
- Add condition:
Page Pathcontains/blog/ - Use this trigger for your Simple Commenter tag
Need help? Contact support.