PHPackages                             digitalpulsebe/craft-utm-tracker - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. digitalpulsebe/craft-utm-tracker

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

digitalpulsebe/craft-utm-tracker
================================

Track landing query parameters in user session

3.0.6(3mo ago)11.5k↑66.7%2MITPHPCI passing

Since Sep 27Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/digitalpulsebe/craft-utm-tracker)[ Packagist](https://packagist.org/packages/digitalpulsebe/craft-utm-tracker)[ RSS](/packages/digitalpulsebe-craft-utm-tracker/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (32)Used By (0)

UTM Tracker plugin for Craft CMS 3, 4 and 5
===========================================

[](#utm-tracker-plugin-for-craft-cms-3-4-and-5)

Get landing page location and query parameters when the user lands on the site. Keeps them in the session for use in forms or other usage in twig variables.

[![Screenshot](resources/img/plugin-logo.png)](resources/img/plugin-logo.png)

Requirements
------------

[](#requirements)

This plugin requires Craft CMS 3.7, 4 or 5.

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

[](#installation)

To install the plugin, follow these instructions.

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Then tell Composer to load the plugin:

    ```
     composer require digitalpulsebe/craft-utm-tracker

    ```

    Or when using Craft 4, use version 2:

    ```
     composer require digitalpulsebe/craft-utm-tracker:^2.0.0

    ```

    Or when using Craft 3, use version 1:

    ```
     composer require digitalpulsebe/craft-utm-tracker:^1.0.0

    ```
3. In the Control Panel, go to Settings → Plugins and click the “Install” button for UTM Tracker.

Configuring UTM Tracker
-----------------------

[](#configuring-utm-tracker)

Configure options in the Craft control panel or create a file in config/utm-tracker.php as a copy of [config.php](src/config.php).

[![Screenshot](resources/img/screenshot_settings.png)](resources/img/screenshot_settings.png)

By default, you should keep track of these UTM tags:

- utm\_source (Campaign Source, example: Google)
- utm\_medium (Campaign Medium, example: email)
- utm\_campaign (Campaign Name, example: xmas2022)
- utm\_term (Campaign Term, example: christmas+presents)
- utm\_content (Campaign Content, example: version+A)

Also, the landing URL and referrer URL are tracked when the session is created.

Other configuration (config/utm-tracker.php) options are:

- 'cookieName': the name of the cookie (when used)
- 'cookieLifetime': lifetime of the cookie in seconds (when used)

Usage
-----

[](#usage)

Available twig variables:

```
{{ craft.utmTracker.landingUrl }}
  {# example: https://example.com/pages/detail #}

{{ craft.utmTracker.absoluteLandingUrl }}
  {# with query parameters, example: https://example.com/pages/detail?param=1 #}

{{ craft.utmTracker.referrerUrl }}
  {# example: https://google.com/ #}

{{ craft.utmTracker.tag('utm_campaign') }}
  {# one tag by key #}

{{ craft.utmTracker.tags|json_encode }}
  {# all tags in an array #}
```

### Using UTM Tracker in combination with Formie

[](#using-utm-tracker-in-combination-with-formie)

1. Drag a custom field 'Tracked Field' on your form
2. Name your field whatever you want, select the source in the dropdown
3. When selecting a Query Parameter (tag) as a source, select the key from the list. It is the same list as the tags you defined in the settings of this app.

[![Screenshot](resources/img/screenshot_formie_settings_01.png)](resources/img/screenshot_formie_settings_01.png)

[![Screenshot](resources/img/screenshot_formie_settings_02.png)](resources/img/screenshot_formie_settings_02.png)

### Using UTM Tracker in combination with Freeform

[](#using-utm-tracker-in-combination-with-freeform)

1. Create hidden fields and add them to your form
2. Render tag with default value filled from the available variable properties

example:

```
{{ form.render({
   'storedValues': {
      'myHiddenField': craft.utmTracker.landingUrl
   }
}) }}
```

Tracking in combination with full page caching
----------------------------------------------

[](#tracking-in-combination-with-full-page-caching)

When the pages are cached entirely (using Blitz, Varnish...) there is no way for Craft CMS to pick up the traffic. You will need to send and retrieve data using javascript asynchronously. But beware: it might increase server load. If your application has very high traffic, consider a javascript only solution.

### Sending data to the backend

[](#sending-data-to-the-backend)

Put this in your twig layout template file:

```
{{ craft.utmTracker.reportScript() }}
```

It will make a POST call to the Craft CMS backend to avoid caching.

### Retrieving data

[](#retrieving-data)

To use the data on cached pages you will need to retrieve it from the api.

Make a call to `https://example.com/actions/utm-tracker/api/data` and you will get this json

```
{
    "data": {
        "queryParameters": {
          "utm_campaign": "campaign"
        },
        "absoluteLandingUrl": "https://example.com/landing-page?utm_campaign=campaign",
        "landingUrl": "https://example.com/landing-page",
        "referrerUrl": null
    }
}
```

Notice: tracking user data
--------------------------

[](#notice-tracking-user-data)

Don't forget to notify the user details are tracked to comply to the GDPR rules. When you select the cookie storage method an extra cookie is created. The name and lifetime of the cookie is configurable in the config file. By default, the key is 'utm\_tracking\_parameters'.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance80

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.6% 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 ~51 days

Recently: every ~28 days

Total

25

Last Release

103d ago

Major Versions

1.3.1 → 2.1.02022-10-10

1.4.0 → 2.2.02022-10-11

1.4.1 → 2.2.12023-02-16

1.4.2 → 2.2.22023-08-10

2.3.0 → 3.0.02024-03-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/102023374?v=4)[Jonathan De Baere](/maintainers/jodeba)[@jodeba](https://github.com/jodeba)

![](https://www.gravatar.com/avatar/fefb6475730ac948fa01153dea60fef3e12e3ee5909c0eb2dca0300bcef03d98?d=identicon)[bartdigitalpulse](/maintainers/bartdigitalpulse)

---

Top Contributors

[![jodeba](https://avatars.githubusercontent.com/u/102023374?v=4)](https://github.com/jodeba "jodeba (82 commits)")[![DieterVanhove](https://avatars.githubusercontent.com/u/33942009?v=4)](https://github.com/DieterVanhove "DieterVanhove (1 commits)")[![john-henry](https://avatars.githubusercontent.com/u/44709?v=4)](https://github.com/john-henry "john-henry (1 commits)")

---

Tags

cmsCraftcraftcmscraft-pluginutm tracker

### Embed Badge

![Health badge](/badges/digitalpulsebe-craft-utm-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/digitalpulsebe-craft-utm-tracker/health.svg)](https://phpackages.com/packages/digitalpulsebe-craft-utm-tracker)
```

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)

PHPackages © 2026

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