WP Manifestindependent plugin directory
manifest / analytics / data-layer-meta-field

Data Layer Meta Field

WordPress plugin: add a per-page/post field that pushes custom JSON to the GTM dataLayer

★ 0stars

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/hagopimasdounian/data-layer-meta-field/archive/refs/heads/master.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A tiny, single-file WordPress plugin that adds a per-page/per-post field for pushing custom values into the Google Tag Manager / analytics dataLayer.

Add structured JSON (or a value) to any page or post in the editor, and the plugin injects a dataLayer.push(...) for it in the site footer — no theme edits, no code, no per-page hardcoding.

What it does

  • Adds a "Data Layer Field" meta box to the post and page editors.
  • Stores whatever you enter in post meta (_data_layer_value).
  • On the frontend (singular views), outputs:
    <script>window.dataLayer = window.dataLayer || []; dataLayer.push( <your value> );</script>

    so GTM and other tags can read it.

Install

  1. Copy data-layer-meta-field.php into wp-content/plugins/data-layer-meta-field/ (or zip the folder and upload it via Plugins → Add New → Upload).
  2. Activate Data Layer Meta Field in the WordPress admin.

Usage

  1. Edit any page or post.
  2. In the Data Layer Field box, paste a JSON object, e.g.:
    { "event": "page_meta", "pageType": "product", "brand": "Rolex" }
  3. Update the page. View it on the frontend — the object is pushed to window.dataLayer and available to GTM.

The value is output as-is into a dataLayer.push() call, so enter valid JSON (or a valid JS expression). Input is admin-only and nonce-protected on save.

Notes

  • No settings page, no dependencies, no external calls.
  • Works alongside GTM; it does not install GTM for you.

License

MIT