Google analytics

i have used https://github.com/frontity/frontity/tree/dev/packages/google-analytics, and when i was monitoring in analytics, it always show only home page as active page, if i do reload on article page then and only then analytic show article as an active page,
is anything other configuration needed after setting package in frontity setting ?
or how can i get it working perfectly?

Helllo @luisherranz ,
i am going to launch my Blog in next 5 days,and older Wordpress blog have a good traffic ,so i need to use google analytics, and its last thing thats remaining, so please help me solve out this problem,
thank you

Hey @mehul can you please give us the specific steps to reproduce your problem? It’s not clear to us what your problem is.

@luisherranz thanks for the response,
i have used google analytics package and done setup like

export default {
  packages: [
    {
      name: "@frontity/google-analytics",
      state: {
        googleAnalytics: {
          trackingId: 'UA-12345678-9'
        },
      },
    },
  ],
};

after this, i was monitoring google analytics in Realtime data so when i was at home page of blog it show acitve page as home page like below
image
but when i go to article page it doesn’t change in active page url,
then if i do refresh active page url change and look like below
image

so the problem is real time data doesn’t change in ssr
can you help me to setup google analytics properly?
is there any other steps to setup google analytics ?

Hi @mehul :wave:

Last week we solved an issue in the @frontity/analytics library (which the @frontity/google-analytics package is using) that caused some pageviews not to be sent (Pageviews not sent when navigating to a link with the same title #460). Maybe is that the problem you have? These changes are not published yet, though, we let you know as soon a the new version is released (probably today or tomorrow).

Also, note that all the analytics package are still in beta. We are working on them in the current sprint to release the first stable versions, so keep tuned!

1 Like

its not problem with same title ,
page view are not even send when title is different,
problem is pageview is sent only once when i visit a website, then it doen’t send page view, if i navigate in website, but if i do refresh, then it works
so can you tell me is there any other things to setup for google analytics?

Well, there is no more setup to do apart from adding the tracking id in frontity.settings.js as you did.

But it could be a bug in the code, because pageviews should be sent automatically each time the link changes using actions.router.set. Could you share a link to a repository or any steps to reproduce the problem? Just to know where the bug could be.

Here is link of repository,
thanks.

1 Like

Thanks, @mehul!

I took a look at the code. The problem is actually caused by the bug I mentioned before so it will be fixed once we publish the new version of @frontity/google-analytics (the bugfix is already done).

Apart from that, I saw that you installed the @frontity/head-tags package, but you don’t have the REST API - Head Tags plugin installed in the WordPress site so the @frontity/head-tags package is not adding titles or meta tags. You need to install that plugin first.

Nice theme, by the way. :blush:

1 Like

@David @SantosGuillamot can you confirm that this should be solved with the latest release? Frontity release: Allow dev, build and serve commands to be configured using environment variables

Yes, that issue David mentioned was solved in the latest release. In order to fix it you just have to update your project following this guide. By the way, we’re planning to do another release during this week or the next one with the first stable version of Google Analytics, although it’s just going to change how it works internally, so just updating the project will be enough again.

1 Like

Thanks @David its working now

1 Like

I want use this, but when I insert the code in my frontity.setting.js this show me server Error in the navigator

  const settings:   {
...
},
  packages: [
{
menu section
},
    {
      name: "@frontity/google-analytics",
      state: {
        googleAnalytics: {
          trackingId: 'UA-12345678-9'
        },
      },
    },
Other package
  ],
};


export default settings

@JmcGraphics, could you share a link to a repository or a codesandbox? What error are you getting in the console?

const settings = {
  name: "mdesigner",
  state: {
    frontity: {
      url: "https://mdesigner.co",
      title: "mdesigner",
      description:
        "En mdesigner sabemos que contar tu historia en la internet es algo difícil por eso queremos ayudarte.",
    },
  },
  packages: [
    {
      name: "@frontity/mdesigner",
      state: {
        theme: {
          menu: [
            ["Home", "/"],
            ["blog", "/blog"],
          ],
          featured: {
            showOnList: true,
            showOnPost: true,
          },
        },
      },
    },
    {
      name: "@frontity/wp-source",
      state: {
        source: {
          api: "https://wp.mdesigner.co/wp-json",
          homepage: "/comienza-a-disenar-tu-historia",
          postsPage: "/blog",
        },
      },
    },
    {
      name: "@frontity/google-analytics",
      state: {
        googleAnalytics: {
          trackingId: "UA-12345678-9",
        },
      },
    },
    "@frontity/tiny-router",
    "@frontity/html2react",
    "@frontity/head-tags",
  ],
};

export default settings;

Thanks @JmcGraphics! :raised_hands:

You posted the console logs from the browser dev tools. Could you share those from the terminal instead?

Maybe you just forgot to install the package using npm.

Yes, I installed the package even though, i just reinstalled without first running the npx frontity dev command and working.

Thanks for you time

1 Like