PHPackages                             claytoncollie/tracking-code-for-google-analytics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. claytoncollie/tracking-code-for-google-analytics

ActiveWordpress-plugin

claytoncollie/tracking-code-for-google-analytics
================================================

Add Google Analytics tracking to your website

2.0.3(3y ago)5171[1 PRs](https://github.com/claytoncollie/tracking-code-for-google-analytics/pulls)GPL-3.0-or-laterPHP

Since Oct 31Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/claytoncollie/tracking-code-for-google-analytics)[ Packagist](https://packagist.org/packages/claytoncollie/tracking-code-for-google-analytics)[ RSS](/packages/claytoncollie-tracking-code-for-google-analytics/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (7)Dependencies (7)Versions (12)Used By (0)

Tracking Code for Google Analytics
==================================

[](#tracking-code-for-google-analytics)

**Contributors:** claytoncollie
**Donate link:**
**Tags:** google, analytics, tracking code, tracking, universal analytics, tracking snippet
**Requires at least:** 5.0
**Tested up to:** 6.6.0
**Requires PHP:** 7.2
**Stable tag:** 2.0.3
**License:** GPLv3 or later
**License URI:**

Simple, lightweight solution for inserting your Google Analytics Universal tracking code.

Description
-----------

[](#description)

Tracking Code For Google Analytics is a simple, lightweight WordPress plugin for inserting your Google Analytics Universal Analytics tracking code. The plugin does one thing and one thing only; prints the standard Google Analytics tacking script to the `` of your website. To insert your tracking ID, navigate to Settings &gt; General and then scroll to the bottom of the page.

### Composer

[](#composer)

`composer require claytoncollie/tracking-code-for-google-analytics`

### Filters

[](#filters)

If you want to set the tracking ID without using the wp-admin user interface, use the filter below.

`add\_filter( 'tracking\_code\_for\_google\_analytics\_id', /\*\* \* Set Google Analytics tracking ID. \* \* @param string $tracking\_id Tracking ID. \* \* @return string \*/ function ( string $tracking\_id ) : string { $tracking\_id

### 'UA-7654321';

[](#ua-7654321)

```
	return $tracking_id;
}

```

);`

### Definitions

[](#definitions)

You can also define the tracking ID in your wp-config.php file with the following snippet.

`define( 'TRACKING_CODE_FOR_GOOGLE_ANALYTICS_ID', 'UA-7654321' );`

### Contributing

[](#contributing)

While the purpose of this plugin is to be very tightly scoped, [issues and pull requests are welcome on GitHub](https://github.com/claytoncollie/tracking-code-for-google-analytics). I do not guarantee that everything will be merged or support will be given.

### Donate

[](#donate)

If you like this plugin and would like to support my work, [please consider a small donation via Coinbase](https://commerce.coinbase.com/checkout/2aa628a4-f12e-4231-a6eb-9887ddc6e9aa).

Installation
------------

[](#installation)

1. Upload `tracking-code-for-google-analytics` to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Navigate to Settings &gt; General &gt; scroll to the bottom of the page
4. Insert your tracking ID
5. Save your changes

Frequently Asked Questions
--------------------------

[](#frequently-asked-questions)

### Why did I build this plugin?

[](#why-did-i-build-this-plugin)

The plugins I have used in the past to solve this problem have too many features for my liking. This plugin is comprised two functions. One for registering a settings field on the Options General page. And another for printing the tracking code to the frontend. I want a lightweight solution for the websites that I build without all of the extra bells and whistles. If you are expecting this plugin to do more or grow in the future, please do not use it.

### Where is the tracking code inserted?

[](#where-is-the-tracking-code-inserted)

The tracking code is inserted into the `` section.

### Will this plugin slow down my website?

[](#will-this-plugin-slow-down-my-website)

No. This plugin is intentionally lightweight. All it does is register a settings field, saves to the database, and then inserts the tracking code. Nothing more.

### I found a bug. How do I report it?

[](#i-found-a-bug-how-do-i-report-it)

### Can I use this plugin with Composer?

[](#can-i-use-this-plugin-with-composer)

Changelog
---------

[](#changelog)

### 2.0.3

[](#203)

- Fix readme markdown
- Bump patch version to deploy

### 2.0.2

[](#202)

- Fix readme markdown
- Bump patch version to deploy

### 2.0.1

[](#201)

- Patch version bump to deploy properly

### 2.0.0

[](#200)

- Major version. Possible breaking changes. Test locally before updating.
- Change callback names. Possible breaking change.
- Bump PHP required version to 7.2
- Add PHP Namespaces
- Add PHP parameter type hinting
- Add PHP return type hinting
- Add automated static analysis GitHub action
- Add automated code linting GitHub action
- Add automated acceptance tests GitHub action
- Add automated WordPress version checker GitHub action
- Add donation link to Coinbase
- Fix URLs in readme files
- Fix markdown syntax for changelog in readme.txt
- Ignore phpstan config from deployed plugin
- Ignore CONTRIBUTING.md from deployed plugin

### 1.1.0

[](#110)

- Add ability to define tracking in wp-config.php
- Update documentation
- Test with WordPress 6.0.0

### 1.0.1

[](#101)

- Update documentation
- Test with WordPress version 5.6.0

### 1.0.0

[](#100)

- Initial release

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance56

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~277 days

Recently: every ~341 days

Total

8

Last Release

85d ago

Major Versions

1.1.0 → 2.0.02022-05-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4236538?v=4)[Clayton Collie](/maintainers/claytoncollie)[@claytoncollie](https://github.com/claytoncollie)

---

Top Contributors

[![claytoncollie](https://avatars.githubusercontent.com/u/4236538?v=4)](https://github.com/claytoncollie "claytoncollie (95 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (4 commits)")

---

Tags

analyticscomposergoogle-analyticswordpresswordpress-plugin

###  Code Quality

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/claytoncollie-tracking-code-for-google-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/claytoncollie-tracking-code-for-google-analytics/health.svg)](https://phpackages.com/packages/claytoncollie-tracking-code-for-google-analytics)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
