Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

blaggacao
Copy link
Contributor

@blaggacao blaggacao commented Jan 19, 2024

see writeup: #62

companion to frappe/frappe#24466

lmkwyt

<!-- 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")
Copy link
Contributor Author

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.

@blaggacao
Copy link
Contributor Author

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);
})();

@blaggacao
Copy link
Contributor Author

ping

@blaggacao
Copy link
Contributor Author

Go for it now. The future is promised to no one. - Wayne Dyer


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

Fears are nothing more than a state of mind. - Napoleon Hill


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

What the caterpillar calls the end of the world, the master calls a butterfly. - Richard Bach


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

Watch your thoughts, they become your words Watch your words, they become your actions Watch your actions, they become your habits Watch your habits, they become your character Watch your character, it becomes your destiny. -


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

You may say Im a dreamer, but Im not the only one, I hope someday you will join us, and the world will live as one. - John Lennon


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

I have just three things to teach: simplicity, patience, compassion. These three are your greatest treasures. - Lao Tzu


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

The important thing is this: to be able at any moment to sacrifice what we are for what we could become. - Charles Dubois


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

Obstacles are those frightful things you see when you take your eyes off your goal. - Henry Ford


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

Our distrust is very expensive. - Ralph Emerson


Kindly help move this PR forward. Many thanks from Yours Sincerely!

@blaggacao
Copy link
Contributor Author

An invincible determination can accomplish almost anything and in this lies the great distinction between great men and little men. - Thomas Fuller


Kindly help move this PR forward. Many thanks from Yours Sincerely!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant