Jump to content

Welcome, Guest!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

  • 0
jmeca

Add google analytics 4

Question

Hello, does anyone know how I can add the code for Google analytics 4 ?

I think it could be done through the custom code, but not functional in multishop.

I think someone had a module for this but I don't remember the name or the page to download it.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
On 4/14/2022 at 9:57 AM, jmeca said:

Hello, does anyone know how I can add the code for Google analytics 4 ?

I think it could be done through the custom code, but not functional in multishop.

I think someone had a module for this but I don't remember the name or the page to download it.

Did you solve this? I'm in the same issue... thanks!

Link to comment
Share on other sites

  • 0

ok, i don't have a multishop, but for a "single" shop setup this works for me:

You create your GA4 tag in google analytics first.
You will get code like this, change the id G-58HPYXXXXX to your own id.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-58HPYXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-58HPYXXXXX');
</script>

copy this code in: (instellingen is dutch for Settings)

ga4.thumb.JPG.d36222bca78d7a98b4f9580c1a54be17.JPG

  • Thanks 1
Link to comment
Share on other sites

  • 0
Posted (edited)

No idea, why this additional weren't implemented multistore ready. Makes not a lot of sense to me. Probably it just got forgotten. When the coder don't work on multistore you can easily forget. 

I don't have time to fix it, but I can give you a simple (dirty) solution:

  1. Open header.tpl in your theme
  2. Search for the "</head>" tag.
  3. Just before add your code in this schema
{if $cart->id_shop==1}/* Your Code for shop with id 1 */{/if}
{if $cart->id_shop==2}/* Your Code for shop with id 2 */{/if}
{if $cart->id_shop==3}/* Your Code for shop with id 3 */{/if}

 

That was the way I started coding 5 years ago ^^

Edited by wakabayashi
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...