-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: generalize tracking feature towards 'Frappe Tag Manager' #63
base: develop
Are you sure you want to change the base?
feat: generalize tracking feature towards 'Frappe Tag Manager' #63
Conversation
see writeup: frappe#62 companion to frappe/frappe#24466
<!-- csrf_token --> | ||
<script async> | ||
if (navigator.doNotTrack != 1) {document.addEventListener("DOMContentLoaded", function() {let b=getBrowser(),q=getQueryParams();import('https://openfpcdn.io/fingerprintjs/v3').then(f=>f.load()).then(fp=>fp.get()).then(r=>{const d={referrer:document.referrer,browser:b.name,version:b.version,user_tz:Intl.DateTimeFormat().resolvedOptions().timeZone,source:q.source,medium:q.medium,campaign:q.campaign,visitor_id:r.visitorId};makeViewLog(d)})})}function getBrowser(){const ua=navigator.userAgent,b={};if(ua.indexOf("Chrome")!==-1){b.name="Chrome";b.version=parseInt(ua.split("Chrome/")[1])}else if(ua.indexOf("Firefox")!==-1){b.name="Firefox";b.version=parseInt(ua.split("Firefox/")[1])}else{b.name="Unknown";b.version="Unknown"}return b}function getQueryParams(){const q={},p=window.location.search.substring(1).split("&");p.forEach(p=>{const [k,v]=p.split("=");q[k]=v});return q}function makeViewLog(d){fetch('/api/method/frappe.website.doctype.web_page_view.web_page_view.make_view_log',{method:'POST',headers:{'Content-Type':'application/json',"X-Frappe-CSRF-Token": frappe.csrf_token},body:JSON.stringify(d)})} | ||
frappe.fel("WebPageView") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to name it frappe.track
as all tag managers that I have seen don't seem to be as explicit, either.
So here: "Frappe Event Log" or fel
, in short.
Alternatively something like matomo does with an array that is the worked on might also be a good idea to have events immediately stacked and the pushed to the server later (after the script is loaded): var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
(function() {
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://cdn.matomo.cloud/<my-site>.matomo.cloud/container_<hash>.js'; s.parentNode.insertBefore(g,s);
})(); |
ping |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
Kindly help move this PR forward. Many thanks from Yours Sincerely! |
see writeup: #62
companion to frappe/frappe#24466
lmkwyt