Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

πŸ‘½ Update the Google Analytics module to GA4 #289

Closed
wants to merge 5 commits into from

Conversation

Log1x
Copy link
Sponsor Member

@Log1x Log1x commented Aug 1, 2023

Pushing this up in response to discourse.

This updates the Google Analytics module to GA4. The anonymize_ip and optimize_id config options have been removed and tags has been added to allow configuring custom gtag commands.

'google-analytics' => [
    'should_load' => true,
    'google_analytics_id' => 'G-XXXXXXXXXX',
    'tags' => [
        ['config', 'test', ['example' => 'value']],
        ['event', ['send' => 'pageview']],
    ],
],

would output:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');

  gtag('config', 'test', {"example":"value"});
  gtag('event', {"send":"pageview"});
</script>

Note

Might be worth exploring renaming the module since GA4 is tied into GTM? 🀷 Not that big of a deal, though.

Todo

  • Update soil.php plugin version.
  • Update CHANGELOG.md version.
  • Decide on release version (not sure what you want to bump the version too with it being a "breaking change")
  • Add back defer?

Change log

Enhancements

  • πŸ‘½ Update the Google Analytics module to GA4
  • πŸ”₯ Remove deprecated anonymize_ip config from the GA module
  • πŸ”₯ Remove deprecated optimize_id config from the GA module
  • ✨ Add tags config to the GA module to create gtag commands

πŸ”₯ Remove deprecated `anonymize_ip` config from the GA module
πŸ”₯ Remove deprecated `optimize_id` config from the GA module
✨ Add `tags` config to the GA module to create `gtag` commands
@QWp6t QWp6t closed this Jan 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants