Skip to content

Commit

Permalink
Merge pull request #198 from spirit1431007/pr-branch
Browse files Browse the repository at this point in the history
适配Google Analytics
  • Loading branch information
mashirozx authored Mar 20, 2020
2 parents 211bea9 + 67dffdb commit 2e5b6ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ function sakura_scripts()
'reply_link_version' => $reply_link_version,
'api' => esc_url_raw(rest_url()),
'nonce' => wp_create_nonce('wp_rest'),
'google_analytics_id' => akina_option('google_analytics_id', '')
));
}
add_action('wp_enqueue_scripts', 'sakura_scripts');
Expand Down
11 changes: 11 additions & 0 deletions js/sakura-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,11 @@ var home = location.href,
$('#loading-comments').after(result.fadeIn(500));
$('ul.commentwrap').after(nextlink);
lazyload();
if (window.gtag) {
gtag('config', Poi.google_analytics_id, {
'page_path': path
});
}
code_highlight_style();
click_to_view_image();
}
Expand Down Expand Up @@ -1838,6 +1843,12 @@ $(function () {
$.getScript("//static.duoshuo.com/embed.js");
}
}
}).on('pjax:end', function() {
if (window.gtag){
gtag('config', Poi.google_analytics_id, {
'page_path': window.location.pathname
});
}
}).on('submit', '.search-form,.s-search', function (event) {
event.preventDefault();
$.pjax.submit(event, '#page', {
Expand Down

0 comments on commit 2e5b6ac

Please sign in to comment.