PageSourceSearch

https://www.suga-dent.com/js/track-tel.js

js suga-dent.com collected 2026-10-05 06:52:40 UTC 1,545 bytes, 58 lines download raw bytes

1/**
2 * TrackTel - tracking events on telephone link taps
3 * v1.2
4 * Released under the MIT license
5 * Last modified at 2016-10-26T11:23+09:00(JST)
6 */
7window.isMobile = navigator.userAgent.match(/(?:iphone|ipod|android.*mobile)/i);
8window.gaEventTrackLimit = 2000;
9document.addEventListener('click', function(e){
10	if( window.isMobile && window.ga && e.target ) {
11		var elem = e.target;
12		while(elem) {
13			if( elem.tagName.toLowerCase() == 'a' ) {
14				var href = elem.getAttribute('href') || '';
15				if( href.match(/^tel\:(.*)$/) ) {
16					e.preventDefault();
17					
18					var tel = RegExp.$1,
19						called = false,
20						trackCallback = function() {
21							if( called ) return false;
22							called = true;
23							location.href = href;
24						};
25					
26					var id = elem.getAttribute('id'), selector;
27					if( id ) {
28						selector = '#'+id;
29					} else {
30						var j = 4, parent = elem.parentElement;
31						selector = 'a';
32						while( j-- ) {
33							if( !parent )
34								break;
35							
36							if( parent.getAttribute('id') ) {
37								selector = '#'+parent.getAttribute('id')+ ' ' + selector;
38								break;
39							}
40							
41							selector = parent.tagName.toLowerCase() + ' ' + selector;
42							parent = parent.parentElement;
43						}
44					}
45					
46					var action = 'telto-' + tel.replace(/\-/g, '');
47					ga('send', 'event', 'Tel', action, selector, {
48						hitCallback  : trackCallback,
49						nonInteraction: true
50					});
51					setTimeout(trackCallback, window.gaEventTrackLimit);
52				}
53				break;
54			}
55			elem = elem.parentElement;
56		}
57	}
58});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.