remove mixpanel + add more matomo tracking

This commit is contained in:
Albert Yi
2018-11-09 15:34:16 -08:00
parent e69cbe7f81
commit c8793457cb
6 changed files with 36 additions and 21 deletions

View File

@@ -34,8 +34,6 @@
<% if CurrentUser.user.custom_style.present? %>
<%= stylesheet_link_tag custom_style_users_path, :media => "screen" %>
<% end %>
<%= raw Danbooru.config.custom_html_header_content %>
<%= yield :html_header %>
<% if Danbooru.config.twitter_site %>
<script type="application/ld+json">
{
@@ -88,17 +86,20 @@
console.warn("Danbooru.error will be deprecated. Use $(window).trigger('danbooru:error', msg) instead.")
$(window).trigger("danbooru:error", msg);
}
window._paq = _paq || [];
<% if CurrentUser.is_member? && !CurrentUser.opt_out_mixpanel? %>
window._paq.push(["setUserId", <%= CurrentUser.id %>]);
<% end %>
window._paq.push(["setDomains", "*.donmai.us"]);
<% if !CurrentUser.opt_out_mixpanel? %>
window._paq.push(["setCustomVariable", 1, "level", <%= CurrentUser.level %>, "visit"]);
window._paq.push(["setCustomVariable", 2, "age", <%= ((Time.now - CurrentUser.created_at) / 1.year).to_i %>, "visit"]);
window._paq.push(["setCustomVariable", 3, "postUpdateCount", <%= CurrentUser.post_update_count %>, "visit"]);
window._paq.push(["setCustomVariable", 4, "favoriteCount", <%= CurrentUser.favorite_count %>, "visit"]);
<% end %>
</script>
<% unless CurrentUser.is_anonymous? %>
<script>
window.Danbooru.mixpanelInit(
"<%= CurrentUser.id %>",
<%= CurrentUser.opt_out_mixpanel? %>,
<%= raw({"$created" =>CurrentUser.created_at.strftime('%F %T'), "$name" => CurrentUser.name, "level" => CurrentUser.level, "upload_count" => CurrentUser.post_upload_count, "post_update_count" => CurrentUser.post_update_count, "note_update_count" => CurrentUser.note_update_count, "favorite_count" => CurrentUser.favorite_count}.to_json) %>
);
</script>
<% end %>
<%= yield :html_header %>
<%= raw Danbooru.config.custom_html_header_content %>
</head>
<%= tag.body **body_attributes(CurrentUser.user) do %>
<%= render "news_updates/listing" %>

View File

@@ -197,6 +197,14 @@
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
<%= auto_discovery_link_tag(:atom, comments_url(:atom, search: { post_id: @post.id }), title: "Comments for post ##{@post.id}") %>
<script>
window._paq = _paq || [];
window._paq.push(["setCustomVariable", 1, "rating", '<%= j @post.rating %>', "page"]);
window._paq.push(["setCustomVariable", 2, "fileSize", <%= @post.file_size %>, "page"]);
window._paq.push(["setCustomVariable", 3, "sourceDomain", '<%= j @post.source_domain %>', "page"]);
window._paq.push(["setCustomVariable", 3, "blocked", <%= @post.levelblocked? %>, "page"]);
</script>
<% end %>
<%= render "posts/partials/common/secondary_links" %>

View File

@@ -12,9 +12,10 @@
<% content_for(:html_header) do %>
<script>
$(function() {
if (typeof window.mixpanel === 'object') {
window.mixpanel.track_forms(".stripe", "Clicked Account Upgrade");
}
$(".stripe").submit(function(e) {
window._paq = _paq || [];
window._paq.push(['trackEvent', 'clickedAccountUpgrade']);
});
});
</script>
<% end %>

View File

@@ -124,7 +124,8 @@
<% content_for(:html_header) do %>
<script>
$(function() {
window.Danbooru.mixpanelEvent("View Account Upgrade");
window._paq = _paq || [];
window._paq.push(['trackEvent', 'viewAccountUpgrade']);
});
</script>
<% end %>

View File

@@ -6,10 +6,14 @@
<% content_for(:html_header) do %>
<script>
$(function() {
if (typeof window.mixpanel === 'object') {
window.mixpanel.track_links('#sign-up-link', 'clicked sign up');
window.mixpanel.track_links('#hide-sign-up-notice', 'hide sign up notice');
}
$("#sign-up-link").click(function() {
window._paq = _paq || [];
window._paq.push(['trackEvent', 'clickedSignUpLink']);
});
$("#hide-sign-up-notice").click(function() {
window._paq = _paq || [];
window._paq.push(['trackEvent', 'clickedHideSignUpLink']);
});
});
</script>
<% end %>

View File

@@ -97,7 +97,7 @@
<%= f.input :disable_responsive_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Disable alternative layout for mobile and tablet" %>
<%= f.input :opt_out_mixpanel, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Opt out of MixPanel tracking" %>
<%= f.input :opt_out_mixpanel, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Opt out of tracking" %>
<%= f.input :custom_style, :label => "Custom <a href='https://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
</fieldset>