|
37 | 37 | "outbound", |
38 | 38 | "emails", |
39 | 39 | "downloads", |
| 40 | + "phones", |
40 | 41 | ]); |
41 | 42 | var fullUrls = setting("fullUrls", "bool", false); |
42 | 43 |
|
|
45 | 46 | outbound: collectTypes.indexOf("outbound") > -1, |
46 | 47 | emails: collectTypes.indexOf("emails") > -1, |
47 | 48 | downloads: collectTypes.indexOf("downloads") > -1, |
| 49 | + phones: collectTypes.indexOf("phones") > -1, |
48 | 50 | // Downloads: enter file extensions you want to collect |
49 | 51 | downloadsExtensions: setting("extensions", "array", [ |
50 | 52 | "pdf", |
|
122 | 124 | metadata.email = event; |
123 | 125 | break; |
124 | 126 | } |
| 127 | + case "phone": { |
| 128 | + var hrefPhone = element.getAttribute("href"); |
| 129 | + event = (hrefPhone.split(":")[1] || "").split("?")[0]; |
| 130 | + metadata.phone = event; |
| 131 | + break; |
| 132 | + } |
125 | 133 | } |
126 | 134 | } |
127 | 135 |
|
|
134 | 142 |
|
135 | 143 | log("collected " + clean); |
136 | 144 |
|
137 | | - return type === "email" |
| 145 | + return type === "email" || type === "phone" |
138 | 146 | ? callback() |
139 | 147 | : window.setTimeout(callback, 5000); |
140 | 148 | } else { |
|
174 | 182 | // Collect email clicks |
175 | 183 | } else if (optionsLink.emails && /^mailto:/i.test(link.href)) { |
176 | 184 | collect = "email"; |
| 185 | + |
| 186 | + // Collect telephone clicks |
| 187 | + } else if (optionsLink.phones && /^tel:/i.test(link.href)) { |
| 188 | + collect = "phone"; |
177 | 189 | } |
178 | 190 |
|
179 | 191 | if (!collect) return; |
|
208 | 220 | if (!href) continue; |
209 | 221 |
|
210 | 222 | // We don't want to overwrite website behaviour so we check for the onclick attribute |
211 | | - if (!link.getAttribute("onclick") && !/^mailto:/.test(href)) { |
| 223 | + if ( |
| 224 | + !link.getAttribute("onclick") && |
| 225 | + !/^mailto:/.test(href) && |
| 226 | + !/^tel:/.test(href) |
| 227 | + ) { |
212 | 228 | collectLink(link, true); |
213 | 229 | } else { |
214 | 230 | collectLink(link, false); |
|
0 commit comments