WP Manifestindependent plugin directory
manifest / analytics / avidly-gtm4wp

Avidly Google Tag Manager WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

Set of base rules to complement GTM setup by pushing page meta data and user information into the dataLayer.

★ 1stars
v1.3.0latest · 3 years ago

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/avidlywordpress/avidly-gtm4wp/archive/refs/heads/main.zip
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Set of base rules to complement GTM setup by pushing page meta data and user information into the dataLayer.

How it works

Hooks into wp_head and pushed meta data into the dataLayer on pageView & click event.

pageView events

Push set of base rules into dataLayer on every page view.

Click events

Detect with JavaScript if element with [data-click-event] has been clicked and push dataLayer values:

'event': 'agtm4wp_click',
'wp_click_url': this.getAttribute('href'),
'wp_click_text': element innerHTML without HTML markup.
'wp_click_type': this.getAttribute('data-click-type'),
'wp_click_event': this.getAttribute('data-click-event'),
'wp_click_current': window.location.href,
'wp_click_dom': parent DOM element name if detected, supports: HEADER, FOOTER, ASIDE, SECTION

Usage

Download the plugin and activate it.

Hooks

Manipulating base

Datalayer properties can be manipulated via custom filters (for example via theme or features plugin). Each key is creating a new dataLayer property.

  1. 'avidly_gtm4wp_sitewide' = Create or modify sitewide properties.
    Array (
    ['event']        => (string)
    ['wp_title']     => (string)
    ['wp_lang']      => (string)
    ['wp_loggedin']  => (bool)
    ['wp_userid']    => (int)
    ['wp_posttype']  => (string)
    ['wp_paged']     => (int)
    )
  2. 'avidly_gtm4wp_single' = Create or modify single post type properties.
    Array (
    ['wp_poststatus'] => (string)
    ['wp_author']     => (string)
    ['wp_postdate']   => (string)
    ['wp_moddate']    => (string)
    ['wp_{tax_slug}'] => (array)
    )
  3. 'avidly_gtm4wp_url_params' = Create or modify URL parameters properties.
    Array (
    ['wp_param_{param}'] => (string)
    )

Example of use:

/**
 * Modify single post type aataLayer properties
 *
 * @param array $datalayer base properties for dataLayer.
 * @param array $post_type where the terms will be detected.
 *
 * @return array $datalayer.
 */
add_filter(
    ['avidly_gtm4wp_single',
    function( $datalayer, $post_type ) {
        // Create new custom property.
        $datalayer['custom_meta'] = 'New custom value';

        // Overwrite exsisting wp_author property for posts only.
        if ( 'post' === $post_type ) {
            $datalayer['wp_author'] = 'New custom value';
        }

        // Remove wp_poststatus base property.
        unset( $datalayer['wp_poststatus'] );

        return $datalayer;
    },
    15,
    2
);

Excluding

Excluded post types, taxonomies and parameters can be manipulated via custom filters (for example via theme or features plugin).

  1. 'avidly_gtm4wp_exclude_post_types' = Create or modify excluded post types.
    Array (
    [0] => 'revision'
    [1] => 'nav_menu_item'
    [2] => 'custom_css'
    [3] => 'customize_changeset'
    [4] => 'oembed_cache'
    [5] => 'user_request'
    [6] => 'wp_block'
    [7] => 'wp_template'
    [8] => 'wp_template_part'
    [9] => 'wp_global_styles'
    [10] => 'wp_navigation'
    [11] => 'polylang_mo'
    [12] => 'acf-field-group'
    [13] => 'acf-field'
    )
  2. 'avidly_gtm4wp_exclude_taxonomies' = Create or modify excluded taxonomies.
    Array (
    [0] => 'post_format',
    [1] => 'language',
    [2] => 'post_translations',
    )
  3. 'avidly_gtm4wp_exclude_params' = Create or modify excluded URL parameters. Defaults to none.

Example of use:

/**
 * Exclude post types properties from dataLayer.
 *
 * @param array $exclude set the excluded post types.
 *
 * @return array $exclude.
 */
add_filter(
    ['avidly_gtm4wp_exclude_post_types',
    function( $exclude ) {
        // Add new exclusion.
        $exclude[] = 'post';

        return $exclude;
    },
    10,
    1
);

Releases

3 releases.

Tag
Published
v1.3.0 latest
Jan 25, 2023 3 years ago
Jun 17, 2022 4 years ago
Jun 17, 2022 4 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

Avidly Google Tag Manager 1.3.0 · audited by WP Registry

No security issues found.

Audited release
1.3.0
Findings
none
Worst severity
—
Content hash
3e2c03a5360cbed9e2ff457d…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.