You are here

timerDynamicElapsedTime

Used by the following Containers: 
Variable Type: 
Custom Javascript
A custom JS function that returns the elapsed time on the page. gtm and its default elapsed time is not as precise as we we would have hoped, not swiss made it seems, so I had to give a 2 second window for the event to properly execute.
	function() {
    var timerElapsedTime = {{timerElapsedTime}};
    if (timerElapsedTime == undefined) {
    	return 'a) Page Loading';
    } else {
        // we have a working clock here
        var timerElapsedTimeInSeconds = Math.floor(timerElapsedTime/1000)
        // three cases by time segments as tests show that Google is not as precise to send the timer trigger :-/
		switch(timerElapsedTimeInSeconds) { 
        	case 14:
            case 15:
            case 16:
        		return 'b) 15 seconds'
        		break;
            case 29:
			case 30:
			case 31:
                return 'c) 30 seconds'
                break;
			case 44:
			case 45:
			case 46:
                return 'd) 45 seconds'
                break;
            case 59:
            case 60:
			case 61:
                return 'e) 1 minute'
                break;
            case 119:
            case 120:
            case 121:
                return 'f) 2 minutes'
                break;
            case 179:
            case 180:
			case 181:
                return 'g) 3 minutes'
                break;
            case 239:
            case 240:
            case 241:
                return 'h) 4 minutes'
                break;
            case 299:
            case 300:
            case 301: // haha like in SEO
                return 'i) more than 5 minutes'
                break;
            default:
                return undefined
        }
    }
}