As you might be able to tell, it’s important for me to know if people are copying scripts from my site. To me, if a high proportion of visitors are copying my code, I know I’ve done my job. It’s simply a fancy way for me to determine engagement… but it’s not a typical behaviour to track – especially not in GA.
A few years ago, you may have read my post about Tynt – a service that lets you track copy/paste in their interface. I liked it, but I didn’t love it because:
- The hefty script added to my page load time
- It saved all the metrics in its own interface (which I never logged into)
- None of the metrics were visible within the context of all my other valuable analytics data
I just had to find a better solution…
Hunting for an Alternative
- I didn’t want another jQuery plugin to keep track of
- I wanted to track more than a handful of letters in the clipboard
- New lines and paragraphs were not represented at all
- The length of the copied string was never tracked
- The events were counted in the bounce rate calculation
- Page paths were not tracked inside the event – making some analyses difficult
Therefore, I hacked away at it, tailoring it to suit my needs. And this is what I came up with:
Tracking Copying to Clipboard in Google Analytics
Simply add this script after your GA script and jQuery library (Note – Requires jQuery and async version of the Google Analytics script):
This tracks copying from anywhere on the page, including line breaks and up to 500 characters of text. There’s room to copy much more (the POST to __utm.gif supports up to 8,192 bytes per request), but I figured, 500 chars should suit most purposes.
Hey, you can always bump this up, yourself.
There you have it! Easy as one, two three. Here’s what it’ll look like in the Google Analytics interface:
Just for the hell of it, here’s an example of the content people have copied from my site. No surprises, here – it’s code!
What sorts of applications would you use this for?
Let me know in the comments…