tracker.ejs 951 B

1234567891011121314151617181920212223242526
  1. <% var title = "" %>
  2. <% if(page.canonical_path == 'index.html') { title = "Landing Page view" %>
  3. <% } else { title = page.content_type.charAt(0).toUpperCase() + page.content_type.slice(1); } %>
  4. <% if(page.canonical_path == 'index.html') { %>
  5. <script>
  6. if (location.hostname !== "localhost" && location.hostname !== "127.0.0.1"){
  7. mixpanel.track("<%- title %>");
  8. } else {
  9. console.log('No tracking in ' + location.hostname);
  10. console.log(`Tracking: \'<%- title %>\'`)
  11. }
  12. </script>
  13. <% } else { %>
  14. <script>
  15. var payload = { content : "<%- page.title %>" };
  16. if (location.hostname !== "localhost" && location.hostname !== "127.0.0.1"){
  17. mixpanel.track("<%- title %> view", payload);
  18. } else {
  19. console.log('No tracking in ' + location.hostname);
  20. console.log(`Tracking: \'<%- title %> view\'`, payload)
  21. }
  22. </script>
  23. <% } %>