Shoora
4/6/2019 - 11:22 PM

Google Analytics Report for Copied Text The report in Google Analytics will show you: Category: Clipboard Action: Copy, cut or paste. Label

Google Analytics Report for Copied Text The report in Google Analytics will show you: Category: Clipboard Action: Copy, cut or paste. Label: The text copied/cutted/pasted. Value: How many characters were copied/cutted/pasted. If you select Pages from the Event report, or Pages as a secondary dimension, you can drill down to the page the text was copied/cutted/pasted from/on. Or even better, create a Custom Report.

// This script for tracking cut/copy/paste in Google Analytics is provided as it is, and was put together by Eivind Savio January 2013. Happy tracking!
// Script from Motyar
function getSelected() {
	if(window.getSelection) {return window.getSelection();}
		else if(document.getSelection) {return document.getSelection();}
	else {
	var selection = document.selection && document.selection.createRange();
	if(selection.text) { return selection.text; }
	return false;
	}
return false;
}
// End script from Motyar
$(document).ready(function() {
$('body').on('copy cut paste', function(ccp) { // Track cut, copy or paste with jQuery.
var selection = getSelected();
var maxLength = 150; // Up to 150 Characters from your text will be tracked. Change this number if you want to track more or less text.
	if(selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) {
	var textLength = selection.length; // How many characters was copied/cutted/pasted.
		if (selection.length > maxLength) {
			selection = selection.substr(0, maxLength) + "..."} // If the text is longer than maxLength, add ... to the end of the text
		else { 
			selection = selection; // If the text is shorter than maxLength, just track the text as it is.
		}
ga('send', 'event', 'Clipboard', ccp.type,selection,textLength);
//_gaq.push(['_trackEvent', 'Clipboard', ccp.type, selection,textLength]); 
// Track copied/cutted/pasted data in Google Analytics as Events
	}
});
});