
October 14, 2017
How To Add a Copyright Notice to the Copied Text (with GTM)
Last week, I had a live Google Tag Manager training session and was showcasing the library of 30+ GTM Recipes to my students. When I mentioned the Copy text recipe by Daniel Carlbom, a student asked: is it the recipe which adds a copyright notice when someone copies and pastes the text?
I said “no”.
“Is it possible?”, he asked.
“Yes, I guess“. And that’s where the idea of this quick blog post was born. I was pretty sure it was possible but I needed to do some research to be sure. In fact, everything happened really fast. In less than 3 minutes, I was already playing around with the solution on my blog.
In this article, I’ll show you how to add a copyright notice to the copied text.

A Copyright Notice? Where?
This is not a very popular solution, but I noticed that some websites (especially news sites) add an additional text when a visitor copies any text of their website. And when he pastes it, that copyright notice gets also pasted.
If you still feel confused, just copy any text from this blog post and paste it anywhere (e.g. Notepad, Word, etc.).
Get it now? After you pasted that text, I have secretly added:
Read more at: https://www.analyticsmania.com/post/copyright-notice-in-copied-text-gtm
Analytics Mania – Digital Analytics Blog
If you want to add some similar text to your blog post, continue reading. Personally, I don’t use it (except on this page (for demonstration purposes)) but maybe some of my readers will find it useful.
The Script
After a quick googling, I’ve found this Stack Overflow thread which discusses the copyright notice script.
<script> function addLink() { //Get the selected text and append the extra info var selection = window.getSelection(), pagelink = '<br /><br /> Read more at: ' + document.location.href + '<br />Analytics Mania - Digital Analytics Blog', // Change this text copytext = selection + pagelink, newdiv = document.createElement('div'); //hide the newly created container newdiv.style.position = 'absolute'; newdiv.style.left = '-99999px'; //insert the container, fill it with the extended text, and define the new selection document.body.appendChild(newdiv); newdiv.innerHTML = copytext; selection.selectAllChildren(newdiv); window.setTimeout(function () { document.body.removeChild(newdiv); }, 100); } document.addEventListener('copy', addLink); </script>
It also automatically fetches the URL of the current page and adds to the copied text. If you want, you can edit notification’s text (just look for pagelink in the script).
pagelink = '<br /><br /> Read more at: ' + document.location.href + '<br />Analytics Mania - Digital Analytics Blog',
That’s it! Copy the entire script, add it as a Custom HTML tag in Google Tag Manager, choose DOM Ready trigger, and you’re good to go!
Don’t forget to test it with a GTM Preview and Debug mode.
Final Words
In this super quick tutorial, I’ve shared a script I’ve found online which adds a copyright notice to the copied text. If a visitor copies at least a tiny fraction of your text and then pastes it somewhere else, the script will also add:
- A short copyright text.
- A link to the page where the text was copied from.
For demonstration purpose, I’ve implemented the script on this page. Go ahead and try it.
Personally, I wouldn’t use on analyticsmania.com it because it would ruin the user experience. But since I have received the question from my student regarding this possibility, I guess, there is a slight demand.
Nonetheless, feel free to use it and let me know if you have any other questions.

14 COMMENTS
Hey, thanks for the article. I wonder, it is possible to add watermark to images when somebody wants them download them?
Thanks
Not sure. My first thought is that the watermark stuff should be done server-side. But I'll dig deeper when I have more time.
Hi Interesting topic. I copied content from this page and pasted on word and notepad but i don't see the secret message. how do I see it?
what am I missing?
Thanks
My bad. I accidentally removed the tag from GTM while doing spring cleaning :) The tag is now back and you can test it by copy-pasting text.
This is a pretty good tag, I will use it to replace the old script that I have used for the past year.
Copy/Paste is blocked on my website. What is any1 copies using inspect url?
Then it will be copied. You cannot protect yourself against that.
Hi Julius
Just found you page and this script - Thank you.
You write that:
"Personally, I wouldn’t use on analyticsmania.com it because it would ruin the user experience."
- Could you elaborate on how it would ruin the user experience?
- Is is negative in regards to indexing of the page or how Google would see the page?
Don't overthink this :) by saying "user experience", I mean that if someone copies a code snippet from my tutorial, that would be ruined with the copyright.
Ah, okay - that makes perfect sense.
Thank you for your quick reply :-)
We have a huge problem with other webshops copying our unique texts, so will try to add the script - that way they are at least reminded that what they are doing is wrong (and illegal).
Have a great weekend!
Hi Julius
Any idea on how to do this when someone sniffs the web and pastes it on another with a robot?
This solution is not for that. You could ask a developer to add a copyright text directly in the source code of the website and make its color not visible for the human eye. At the same time, the robot will probably scrape that text too.
GTM is not for the problem you have.
Yes, Yes i know that this solution is not for that.
OK, copyright text not visible is a solution and is possible to add with a GTM Tag... ;)
Thkx
Not really. Many scrapers don't support javascript. No JS support = no GTM support.