Guide on how to track people copying text using GTM and GA

Another micro interaction to pick up on is when people copy text from your content. If you’re writing about technical subjects or have quotable content, it might get copied and shared elsewhere.

If you’re writing scripts, code or even Excel formulae, there’s a strong chance people will copy your text. And, in those types of articles, that’s the Goal! Measuring performance for differing article types is crucial and this is a great way to understand if people are harvesting your technical content.

First, make a new HTML Tag and add the following with a Trigger of All Pages

<script>
    try {
        document.querySelector('body').addEventListener("copy", function () {
            window.dataLayer.push({
                'event': 'text-copied'
            });
        });
    } catch (e) {}
</script>

To explain, this script watches for any “copy” actions that occur within the body of the webpage. If you want to adjust the target where copying is tracked, change the body value on line 3 for a different HTML element. This eventListener looks for CTRL+C, CMD+C and right click copy actions.

trigger nametrigger typevalue
CE – Content Engagement – Text CopiedCustom Eventtext-copied

Finally, create a new Universal Google Analytics Tag with the following settings

tag settingvalue
Tag NameGA – Event – User Engagement – Text Copied
Track TypeEvent
CategoryKey Engagement
ActionText Copied
LabelEmpty
TriggerCE – Content Engagement – Text Copied

Ensure you add your GAID or GA Settings Variable to the tag and save. If you preview the container changes and visit your site, any copy actions within the body of your site will be sent as Events to Google Analytic. If this is a main Goal for your content, set it up as an actual Goal in GA to track conversion rates on any piece of content you write.