Facebook 

SMFHacks.com - Celebrating 20 Years!

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4341
Latest: jmac32here
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 44306
Total Topics: 7676
Most Online Today: 365
Most Online Ever: 27044
(May 30, 2026, 09:10:16 pm)
Users Online
Members: 0
Guests: 214
Total: 214

Author Topic: [Mod]SMFHacks Analytics for Google  (Read 27833 times)

0 Members and 0 Guests are viewing this topic.

[Mod]SMFHacks Analytics for Google
« on: »
SMFHacks Analytics for Google




https://www.smfhacks.com/index.php?action=downloads;sa=view;down=263

SMFHacks Analytics for Google
Version: 1.0.0
Author: vbgamer45 - https://www.smfhacks.com
License: MIT
Compatible with: SMF 2.1.x



Description

A comprehensive Google Analytics 4 (GA4) integration for Simple Machines Forum. This modification provides deep analytics tracking, server-side event collection via the Measurement Protocol, Google OAuth2 API access, and in-admin reporting - all without modifying any core SMF files.



Features

Tracking
  • GA4 tracking code (gtag.js) automatically injected on all forum pages
  • Track registered members across devices using their user ID
  • Track which theme/style users are using
  • Track boards via custom GA4 dimension
  • Track topics via custom GA4 dimension
  • Track user groups with configurable priority ordering
  • Client-side error tracking (JavaScript errors, console errors, failed image loads, unhandled promise rejections)

Event Tracking
  • User registrations (sign_up event)
  • User logins (login event)
  • New topic creation (create_content event)
  • New reply/post creation (create_content event)
  • Personal messages sent (create_content event)
  • Attachment downloads tracked server-side via Measurement Protocol (file_download event)
  • Paid subscription views, checkout, and purchases tracked as GA4 eCommerce events (view_item_list, begin_checkout, purchase)
  • UTM parameters automatically added to links in outgoing forum emails

Google Analytics API Integration
  • OAuth2 authentication using your own Google Cloud credentials
  • Browse and select existing GA4 properties from your Google Analytics accounts
  • Create new GA4 properties and data streams directly from the admin panel
  • Measurement Protocol API secret auto-generated
  • Custom dimensions automatically created in your GA4 property (board_id, topic_id, style_id, user_group_id, user_id, and error tracking dimensions)

In-Admin Reporting
  • Dashboard - Realtime visitor map showing active users by country (Google GeoChart, auto-refreshes every 30 seconds)
  • Charts - Configurable line charts with date range, dimension (OS, browser, country, city, page, device, language, board, topic), metric (page views, sessions, active users, events, new users), and minimum value filter
  • Heat Map - Weekly activity heatmap (hour of day x day of week) with configurable metric, weeks of data, and end date
  • Errors - Client-side error report showing error type, message, page URL, location, line number, and occurrence count



Requirements

  • SMF 2.1.x
  • PHP 7.0+ with cURL extension enabled
  • A Google Analytics 4 property (created automatically or select an existing one)
  • Google Cloud OAuth2 credentials (Client ID and Client Secret) - see setup instructions below



Installation

1. Install via SMF Package Manager (Admin > Packages > Install a Package)
2. After installation you will be redirected to the settings page



Setup Instructions

Step 1: Create Google Cloud OAuth Credentials
1. Go to Google Cloud Console - Credentials
2. Create a project (or select an existing one)
3. Enable the following APIs:
   - Google Analytics Admin API
   - Google Analytics Data API
4. Go to Credentials > Create Credentials > OAuth 2.0 Client ID
5. Application type: Web application
6. Add your forum URL as an Authorized redirect URI:
   
Code: [Select]
https://yourforum.com/index.php?action=smfhacks_analytics;sa=oauth_callback7. Copy the Client ID and Client Secret

Step 2: Configure the Modification
1. Go to Admin > Configuration > Analytics for Google > Settings
2. Enter your OAuth Client ID and Client Secret
3. Click Save
4. Click "Link Google Account" and authorize access
5. Select an existing GA4 property or create a new one
6. The Measurement ID and API Secret will be auto-populated
7. Custom dimensions are automatically created in your GA4 property
8. Configure which tracking features and events you want enabled
9. Set user group priority order if desired

Step 3: Enable Enhanced Measurement (Recommended)
In your Google Analytics account:
1. Go to Admin > Property > Data Streams
2. Click your web data stream
3. Enable Enhanced Measurement for automatic tracking of scrolling, outbound clicks, site search, video engagement, and file downloads



How It Works

Client-side tracking: The gtag.js script is injected on every page via SMF's integrate_load_theme hook. Custom dimensions (board, topic, style, user group) are set based on the current page context.

Event queue: Forum actions (login, registration, topic/post creation, PMs) are queued in the PHP session and fired as gtag() calls on the user's next page load.

Server-side tracking: Attachment downloads and paid subscription purchases are tracked via the GA4 Measurement Protocol directly from PHP, since these actions don't render a page.

Reporting: Admin report pages fetch data from the Google Analytics Data API via an AJAX proxy endpoint, keeping page loads fast.

100% hook-based: This modification uses 14 SMF integration hooks and does not modify any core SMF files.



Hooks Used

  • integrate_actions
  • integrate_admin_areas
  • integrate_load_theme
  • integrate_pre_javascript_output
  • integrate_pre_css_output
  • integrate_login
  • integrate_register_after
  • integrate_create_topic
  • integrate_create_post
  • integrate_personal_message_after
  • integrate_download_request
  • integrate_outgoing_email
  • integrate_exit
  • integrate_daily_maintenance



Uninstallation

Uninstall via SMF Package Manager. All hooks are automatically removed, all files are deleted, and all settings are cleaned from the database. No traces are left behind.



Support

For support, bug reports, and feature requests visit https://www.smfhacks.com



Changelog

1.0.0 - Initial release
  • GA4 tracking code injection with custom dimensions
  • Google OAuth2 integration with property selection and creation
  • Forum event tracking (login, registration, topics, posts, PMs, downloads)
  • Client-side error tracking
  • Paid subscription eCommerce tracking
  • Email UTM tagging
  • In-admin reporting (dashboard, charts, heat map, errors)
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
19020 Views
Last post August 18, 2006, 10:00:30 pm
by arslan
1 Replies
13216 Views
Last post April 17, 2007, 08:34:00 am
by Jump1979man
9 Replies
27410 Views
Last post March 22, 2012, 06:24:50 am
by insy111
1 Replies
12588 Views
Last post March 14, 2010, 07:53:25 pm
by SMFHacks
2 Replies
9956 Views
Last post February 12, 2013, 06:49:50 pm
by tekgik

+- Recent Topics

Registration - anti bot pattern matching by SMFHacks
November 01, 2026, 07:20:17 pm

EZPortal 8 by davejo
October 21, 2026, 01:01:54 pm

Downloads Pro 7.0 Released by SMFHacks
October 07, 2026, 07:35:30 pm

[Mod]ActivityPub Federation for SMF 2.1 by SMFHacks
October 01, 2026, 05:03:45 pm

Newsletter Pro 4.0 Released by SMFHacks
September 23, 2026, 08:08:24 pm

Can't remove or restore any item from the recycle bin by SMFHacks
September 22, 2026, 11:01:51 am

MCP Server for SMF 2.1 - let Claude, ChatGPT or Cursor run your admin chores by SMFHacks
September 12, 2026, 02:50:45 pm

Suggestions for improvements to Ultimate Shoutbox & Chatroom by davejo
September 02, 2026, 01:35:09 am

Automatic Sorting of Categories by Kiwi
August 31, 2026, 12:36:09 am

' appears as ' in Most Viewed (and Recent Items ?) by SMFHacks
August 22, 2026, 11:01:56 pm

Powered by EzPortal