首页 问答 正文

WordPress中的谷歌分析插件有哪些?

注册会员 / 悠然自学 / 2023-06-11/ 浏览 147 次

  1. Google Analytics by MonsterInsights
  2. Google Analytics Dashboard Plugin for WordPress (GADWP)
  3. Analytify – Google Analytics Dashboard Plugin for WordPress
  4. WP Google Analytics Events
  5. Google Analytics Dashboard for WP by ExactMetrics
  6. Ultimate Google Analytics – Dashboard Plugin for WordPress
  7. DuracellTomi's Google Tag Manager for WordPress
  8. Google Analytics Counter Tracker
  9. Site Kit by Google
  10. WPForms

示例代码:

  1. Google Analytics by MonsterInsights:
<?php
if ( function_exists( 'wp_enqueue_script' ) ) {
    wp_enqueue_script( 'monsterinsights-gtag', plugins_url( '/js/dist/gtag.js', __FILE__ ), array( 'jquery' ), MONSTERINSIGHTS_VERSION, true );
    wp_add_inline_script( 'monsterinsights-gtag', 'window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '' . $ua_code . '');' );
}
?> 
  1. Google Analytics Dashboard Plugin for WordPress (GADWP):
<?php
if ( function_exists( 'wp_enqueue_script' ) ) {
    wp_enqueue_script( 'gadwp-gtag', plugins_url( '/js/gtag.js', __FILE__ ), array( 'jquery' ), GADWP_CURRENT_VERSION, true );
    wp_add_inline_script( 'gadwp-gtag', 'window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '' . gadwp_get_trackingcode() . '');' );
}
?> 
  1. Analytify – Google Analytics Dashboard Plugin for WordPress:
<?php
if ( function_exists( 'wp_enqueue_script' ) ) {
    wp_enqueue_script( 'analytify-gtag', plugins_url( '/dist/js/gtag.js', __FILE__ ), array( 'jquery' ), ANALYTIFY_PLUGIN_VERSION, true );
    wp_add_inline_script( 'analytify-gtag', 'window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '' . $tracking_code . '');' );
}
?> 
大家谈论
    我的见解