Google Tag Manager package

I was thinking about changing the format we use to add events and pageviews to the data layer.

For events I think it’s just okay at it is.

For pageviews, I would change the event name to frontityPageview or only pageview, and move title and link to the root level. Something like this:

dataLayer.push({
  event: "pageview",
  title: "The Beauties Of Gullfoss - Frontity Test",
  link: "/2016/the-beauties-of-gullfoss/",
});

The idea is simply use the same properties pageviews and events already have and add an event property with the event name.

Well, I don’t think this small change is worth it though. :slightly_frowning_face:

What do you think, guys?

Why do you think so?

Because I want to finish this and not to continue with more changes! :laughing:

Anyways, what do you think about the format I proposed for pageviews? The only thing that still doesn’t seem to fit for me is the event name. Could it be something as general as "pageview"? Or should it be more Frontity-specific, like "frontityPageview"? Or something different?

Better now than later.

I think pageview is better. I like your new proposal, it looks neat :slightly_smiling_face:

The first stable version for the @frontity/google-tag-manager-analytics package is ready!

Here is a summary of the changes we did:

  • The package was renamed from @frontity/google-tag-manager to @frontity/google-tag-manager-analytics to remark that it belongs to the Frontity analytics group of packages.

  • It now uses the new version of the analytics library under the hood.

  • Settings haven’t changed, but the format used to add pageviews to the Google Tag Manager’s data layer has. Now it is as follows:

    dataLayer.push({
      event: "pageview",
      title: "The Beauties Of Gullfoss - Frontity Test",
      link: "/2016/the-beauties-of-gullfoss/",
    });
    

    Users updating this package to the new version have to update their triggers and tags in their GTM containers in order to match the new format.

    The format for other events remains the same.

2 Likes

This has been included in the latest release :tada: : Read the full Release Announcement.

3 Likes

2 posts were split to a new topic: How to integrate google tag manager analytics

There is a problem, where the default Google Tag Manager triggers, like clicks, don’t work. This will be solved once this Pull Request is merged.

1 Like

6 posts were split to a new topic: Problem with Google Tag Manager Package

We have already released the fix for this :tada: : Read the full Release Announcement .

1 Like

@SantosGuillamot @luisherranz

I am getting below error once I add to the packages in frontity.settings.js

TypeError: Cannot convert undefined or null to object
  at Function.keys (<anonymous>)
  at getKeys (webpack-internal:///./node_modules/deepmerge/dist/umd.js:2:1009)
  at mergeObject (webpack-internal:///./node_modules/deepmerge/dist/umd.js:2:1282)
  at deepmerge (webpack-internal:///./node_modules/deepmerge/dist/umd.js:2:2056)
  at state.frontity.packages.forEach.name (webpack-internal:///./node_modules/@frontity/core/src/utils/merge-packages.ts:8:484)
  at Array.forEach (<anonymous>)
  at __webpack_exports__.default (webpack-internal:///./node_modules/@frontity/core/src/utils/merge-packages.ts:8:226)
  at __webpack_exports__.default (webpack-internal:///./node_modules/@frontity/core/src/server/store.ts:5:271)
  at app.use (webpack-internal:///./node_modules/@frontity/core/src/server/index.tsx:61:68)
  at process._tickCallback (internal/process/next_tick.js:68:7)

is there any specific version required for any of the packages? Do any additional packages need to be installed to make this work?

Below are some core packages and it’s versions
@frontity/core : 1.9.0
@emotion/core : 10.0.35
@frontity/analytics : 1.4.0
@frontity/connect : 1.1.3
@frontity/google-tag-manager-analytics : 1.2.1

Yes, please update the Frontity packages to their latest version. You can follow this guide: Keep Frontity Updated - Frontity Docs

Thanks @luisherranz
After updating packages now it’s no longer showing any errors, but I am getting 404 pages on all the Pages and post URLs. only homepage is working

if I remove
"homepage": "/home",
from frontity.settings.js then all other page starts working but my home page does not show the page I want as home page, I have already set the same page as Home Page in wordpress settings.

I think this change is causing the issue - Fix pattern of `homepage` internal redirect · frontity/[email protected] · GitHub

If I revert this change in the package then the home page and all other pages are working fine.

@david @SantosGuillamot , could you please take a look at this?

Sure, I will try to reproduce it. In the meantime, @parth.nextbits could you please share the content of your frontity.settings.js file? If you could also provide a repository with the code of your project, it will be really useful as well.

@SantosGuillamot

I am not allowed to disclose that details yet, so I can not share the repo as it’s private right now.

below is my frontity.settings.js file which is working after updating @frontity/wp-source to 1.11.2 version. but not working with the 1.11.3 version

const settings = {
  "name": "test",
  "state": {
    "frontity": {
      "url": "http://test.frontend.com/",
      "title": "Site Title",
      "description": "Meta Description"
    }
  },
  "packages": [
    {
      "name": "@frontity/mars-theme",
      "state": {
        "theme": {
          "menu": [
            [
              "Home",
              "/"
            ],
            [
              "Nature",
              "/category/nature/"
            ],
            [
              "Travel",
              "/category/travel/"
            ],
            [
              "Japan",
              "/tag/japan/"
            ],
            [
              "About Us",
              "/about-us/"
            ]
          ],
          "featured": {
            "showOnList": false,
            "showOnPost": false
          }
        }
      }
    },
    {
      "name": "@frontity/wp-source",
      "state": {
        "source": {
          "url": "https://admin.wordpress.com/",
          "homepage" : "/home",
          "postTypes": [
            {
              type: "video",
              endpoint: "video"
            },
            {
              type: "voice",
              endpoint: "voice"
            },
            {
              type: "our-stories",
              endpoint: "our-stories"
            },
            {
              type: "press-releases",
              endpoint: "press-releases"
            },
            {
              type: "in-the-news",
              endpoint: "in-the-news"
            },
            {
              type: "events-and-travel",
              endpoint: "events"
            },
            {
              type: "our-work",
              endpoint: "our-work"
            },
            {
              type: "disasters",
              endpoint: "disasters"
            }
          ],
          taxonomies: [

            {
              taxonomy: "our-collection",
              endpoint: "our-collection",
              postTypeEndpoint: "our-stories"
            },
            {
              taxonomy: "voice-collection",
              endpoint: "voice-collection",
              postTypeEndpoint: "voice"
            }
          ]
        }
      }
    },
    {
      name: "@frontity/google-tag-manager-analytics",
      state: {
        googleTagManagerAnalytics: {
          containerId: "GTM-TEST",
        },
      },
    },
    "@frontity/tiny-router",
    "@frontity/html2react",
    "@frontity/head-tags"
  ]
};

export default settings;

You’re totally right. I was able to reproduce the error and it seems it’s caused by the function you mentioned before. I have just opened an issue to talk about it and solve it → Frontity returns a 404 in all pages when state.source.homepage is defined · Issue #805 · frontity/frontity · GitHub

1 Like

Hi @parth.nextbits We have just made a release with this fix. Could you please update your project following this guide and check if your issue is solved? :slightly_smiling_face:

2 Likes

@SantosGuillamot
After updating to the latest version now working fine all the pages
Thanks for a quick fix.

3 Likes

2 posts were split to a new topic: Bounce rate drop