nystudio107 / craft-instantanalytics-ga4

Instant Analytics brings full Google GA4 server-side analytics support to your Twig templates and automatic Craft Commerce integration
Other
3 stars 4 forks source link

No titles being reported (inc. sort of fix!) #4

Closed bossanova808 closed 1 year ago

bossanova808 commented 1 year ago

Ok, so I am getting my templates titles instead of actual titles.

I dug in a little bit, and I can see where you're trying to get the plugin:

https://github.com/nystudio107/craft-instantanalytics-ga4/blob/a5ce1b1643fd01d53e465a69522ed4fcd20bd4fe/src/InstantAnalytics.php#L131

is where it seems to be going wrong.

...if I log that I get:

 [info] 2023-06-15 10:35:02 SEOmatic is (init)

To test, I added:

InstantAnalytics::$seomaticPlugin = Craft::$app->getPlugins()->getPlugin("seomatic");

Just above this:

https://github.com/nystudio107/craft-instantanalytics-ga4/blob/a5ce1b1643fd01d53e465a69522ed4fcd20bd4fe/src/helpers/Analytics.php#L34

...which solved the issue, and I can now see titles being reported correctly.

So, therefore, some kind of init order issue, I think. Perhaps you should defer that to a bit later? You'll know much better than me, but that's the root cause of the issue I am seeing.

khalwat commented 1 year ago

Addressed in: https://github.com/nystudio107/craft-instantanalytics-ga4/commit/b4fdd0da5c3b430618b392607e7aa8f937d820c1

You can try it now by setting your semver in your composer.json to look like this:

    "nystudio107/craft-instantanalytics-ga4": "dev-develop-v4 as 4.0.0-beta.2”,

Then do a composer clear-cache && composer update