Skip to main content

Google Tag tracking

3 weeks 5 hours ago #100000540 by askjim
Google Tag tracking was created by askjim
-- HikaShop version -- : 6.8.0
-- Joomla version -- : 6.2.0
-- PHP version -- : 8.4.27
-- Browser(s) name and version -- : Chrome 156.0

Hello,
I'm using Joomla 6.2.0, HikaShop 6.8.0 and YOOtheme Pro 5.0.53.
The HikaShop Google Analytics 4 plugin (
Code:
hikashop_ga4
) is enabled and successfully sends
Code:
view_item
events to GA4.
However, when customers add products to the basket using the AJAX Add to Cart button, no
Code:
add_to_cart
event appears in Google Tag Assistant, Chrome Network or the browser's Google data layer.
The basket updates successfully, and the HikaShop AJAX request returns the correct product information.
Could you please confirm:
  1. Does the HikaShop 6.8.0 GA4 plugin support the
    Code:
    add_to_cart
    event?
  2. If so, is any additional configuration required for AJAX Add to Cart buttons?
  3. If not, what is your recommended method for implementing GA4
    Code:
    add_to_cart
    tracking?
Many thanks.
Jim

Please Log in or Create an account to join the conversation.

3 weeks 1 hour ago #100000541 by nicolas
Replied by nicolas on topic Google Tag tracking
Hi,

HikaShop's Google Analytics 4 plugin did not send any add_to_cart event so far: up to version 1.5.9 it sent view_item_list, view_item, view_cart, begin_checkout, add_shipping_info, add_payment_info and purchase, so nothing was missing in your configuration.

We have added it: version 1.6.0 of the plugin, available now, sends an add_to_cart event each time a customer adds a product with an AJAX add to cart button, on the listings and on the product page, with the product's code and name, the quantity added, its unit price, the currency, its brand and its categories. It goes through the same gtag code as the other events, so it shows in Tag Assistant and in the dataLayer right after the click, and it follows your cookie consent setting like the rest of the plugin.

To get it, download the plugin from www.hikashop.com/marketplace/product/108...egration-google.html (or from your account, or Joomla's updater when it shows the update) and install it over the current one; your settings are kept. No other setting is needed.

If after the update the event still does not appear when you click the button, please tell us which button you use (a HikaShop add to cart button, or one built with YOOtheme Pro's builder) so that we can check how it calls the cart.

Please Log in or Create an account to join the conversation.

3 weeks 2 minutes ago #100000548 by askjim
Replied by askjim on topic Google Tag tracking
Thank you Nicolas, I will have a look at this tomorrow.

Regard

Jim

Please Log in or Create an account to join the conversation.

2 weeks 6 days ago #100000560 by askjim
Replied by askjim on topic Google Tag tracking
Hi Nicolas

**Subject: GA4 plugin 1.6.0 – integration with YOOtheme Pro Consent Manager**
I'm using HikaShop 6.8.0 with the HikaShop GA4 plugin 1.6.0, Joomla 6.2.0 and YOOtheme Pro 5.0.53.

YOOtheme Pro's Consent Manager is configured for GDPR opt-in, with Google Analytics using Advanced Consent Mode.

The HikaShop GA4 plugin currently has **Cookie consent integration = None (track immediately)**.

I've found that the HikaShop plugin outputs `gtag('config', 'G-*my tag code*')` before YOOtheme outputs `gtag('consent', 'default', ...)`. As a result, `_ga` cookies are being created before visitors make a consent choice.

The GA4 ecommerce events, including `add_to_cart` and `purchase`, are working correctly, and I want to preserve them.

Could you please advise:

1. Can the **Custom JavaScript condition** option integrate with YOOtheme Pro's Consent Manager?
2. What JavaScript condition should be used?
3. Will this prevent GA4 initialisation before consent while allowing ecommerce events after consent is granted?

Thank you.

Please Log in or Create an account to join the conversation.

2 weeks 6 days ago #100000564 by nicolas
Replied by nicolas on topic Google Tag tracking
Hi Jim,

Yes, the Custom JavaScript condition setting can work with YOOtheme Pro's Consent Manager. Since you use Advanced Consent Mode, though, you do not want the plugin to wait for consent: in that mode Google's tag is meant to run from the start, as long as gtag('consent', 'default', ...) comes before gtag('config', ...). Your page has them in the wrong order because the plugin, with "None", adds its code in the head before the script YOOtheme adds at the end of the head.

The setting just needs to delay the plugin's code until the page has loaded, which is after YOOtheme's consent default. In the plugin's settings, set:

- Cookie consent integration: Custom JavaScript condition

- Use prior blocking: No

- The custom code: consentGiven = true;

With this, the plugin loads Google's tag and sends its events once the page is loaded. YOOtheme's consent default (analytics_storage denied until the visitor accepts) is already in place by then, so no _ga cookie is created before consent and the hits are sent as cookieless pings. When the visitor accepts in YOOtheme's banner, YOOtheme sends the consent update and the next events, add_to_cart and purchase included, are sent normally with the cookies. We tested this order with YOOtheme Pro's consent code as it appears on your home page: before the change the _ga cookie was created on page load and the hits carried no consent state; after it, no _ga cookie until the consent was granted, the hits were sent with consent denied, and the add_to_cart sent after accepting went with consent granted.

To answer your three questions:

1. Yes. YOOtheme Pro exposes the visitor's choice in JavaScript (yootheme.consent.hasConsent), so a condition can read it.

2. For Advanced Consent Mode, consentGiven = true; as above. If you ever switch to Basic Consent Mode (nothing sent to Google before consent), use the condition in the attached ga4-yootheme-strict-condition.txt instead. Keep in mind that the plugin then only starts on the page after the visitor accepts, so the events of the page where they click the banner are not sent.

3. Yes, with consentGiven = true; Google's tag only starts after YOOtheme's consent default, and the ecommerce events keep being sent, as cookieless pings before consent and normally after it.

One more thing we noticed on your site: Google Analytics is loaded twice with the same measurement ID, once by YOOtheme Pro's Google Analytics service (which is what outputs the consent default) and once by the HikaShop plugin. Each one calls gtag('config', ...), so GA4 records two page_view events for each page viewed. This is already the case today, and the change above does not affect it. The plugin's ecommerce events (view_item, add_to_cart, purchase...) are only sent once. If your page view numbers look doubled in GA4, that is the reason.

Please Log in or Create an account to join the conversation.

2 weeks 6 days ago #100000569 by askjim
Replied by askjim on topic Google Tag tracking
Following your advice, the GA4 consent integration is now working correctly. Thank you.

I've noticed a separate issue with the purchase event generated by HikaShop GA4 plugin 1.6.0.

For a test order, the values were:

Product: £13.50

Shipping: £4.50

Order total: £18.00

The GA4 purchase event reported:

value=18

shipping=4.5

tax=3

currency=GBP

Google's recommended GA4 ecommerce implementation excludes shipping and tax from the purchase value.

Is there a setting or supported method to change the HikaShop GA4 plugin's purchase value calculation without affecting the other ecommerce events?

I'd prefer to avoid modifying plugin source files, as changes could be overwritten by future updates.

Thank you.

Please Log in or Create an account to join the conversation.

2 weeks 5 days ago #100000572 by nicolas
Replied by nicolas on topic Google Tag tracking
Hi Jim,

There was no setting for it: the plugin always sent the order total as the purchase value, shipping and taxes included.

We have added one. Version 1.6.1 of the plugin, available now, has a new "Purchase value" setting with two choices:

- Order total: the total the customer paid, as until now (the default, so nothing changes until you switch it).

- Products, without shipping and taxes: the products after discounts and coupons, without shipping, payment fee and taxes, as Google recommends.

Shipping and tax are still sent in their own shipping and tax parameters either way, and the other ecommerce events (view_item, add_to_cart, begin_checkout...) are not affected. With the second choice, your test order would be sent with value=11.25 (your £13.50 product without its VAT), shipping=4.5 and tax=3. If you set a Google Ads purchase conversion label in the plugin, that conversion uses the same value as the purchase event.

To get it, download the plugin from www.hikashop.com/marketplace/product/108...egration-google.html (or from your account, or Joomla's updater when it shows the update) and install it over the current one: your settings, including the consent ones, are kept. Then select "Products, without shipping and taxes" in the plugin's "Purchase value" setting and save. No change to the plugin's files is needed, so future updates will keep it.

Please Log in or Create an account to join the conversation.

Time to create page: 0.083 seconds
Powered by Kunena Forum