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 the data-id
data attribute ensures your public key is always passed correctly, even though
GTM may strip query parameters.
Prerequisites
- A Google Tag Manager account
- GTM container installed on your website
- Your Simple Commenter project public key 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-id="sc_your_project_key"
defer
></script>
Replace sc_your_project_key with your project's public key 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.id = k;
document.head.appendChild(s);
})("sc_your_project_key");
</script>
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)
- Make sure the public key in your tag matches your project in the dashboard
- 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.