Commerce Google Tag Manager module provides following rule actions:
1. Send "Add to Cart" event to google analytics via GTM
2. Send "Remove from Cart" event to google analytics via GTM
3. Send "Checkout" event to google analytics via GTM
4. Send "Purchase" event to google analytics via GTM

Created following 4 rules:
1. Send Add to Cart Details to GA via GTM
Event: After adding a product to the cart
Action: Send "Add to Cart" event to google analytics via GTM
2. Send Remove From Cart to GA via GTM (Not having any session in GTM to track these details)
Event: After removing a product from the cart
Action: Send "Remove from Cart" event to google analytics via GTM
3. Send Checkout Complete Details to GA via GTM
Event: Completing the checkout process
Action: Send "Purchase" event to google analytics via GTM
4. Send Checkout Process Details to GA via GTM
Event: Process a change to the checkout page (Enabled Commerce Rules Extra module for this event)
Action: Send "Checkout" event to google analytics via GTM

Using above 4 rules data is tracking properly under Ecommerce -> Shopping Analysis->Shopping Behavior Analysis to 'All Sessions', 'Sessions with Add to Cart', 'Sessions with Check-Out', 'Sessions with Transactions' but 'Sessions with Product Views' is empty. Please help.

How to track Sessions with Product Views data to Google Analytics via GTM in drupal 7?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vasike’s picture

Version: 7.x-1.1 » 7.x-2.x-dev
Category: Support request » Feature request

i think is about the version 2 of the module and it seems not implemented yet.

Not sure how this could be done, as there could be different implementations for Drupal Commerce products and products displays.
Maybe an API that could be customized as needed.

prachi@fantailtech.com’s picture

Issue tags: +Google Tag Manager, +Commerce Google Tag Manager
vasike’s picture

Status: Active » Needs review
FileSize
8.67 KB

Here is patch for this:

  • It builds new class for ProductDisplays : CommerceGoogleTagManagerActionProductDetails.php
  • It build new helper methods to get the products data for a product display and to build the product data for a commerce product entity
  • Use the new method also for line items to the product data
  • This could be used for example for "Content is viewed of type Product" events, so we need event that provides "product display" nodes
  • It changes a little the pushCommerceData method as for this we do not have an event for GTM.
vasike’s picture

New patch with 2 updates for previous patch:
- correct the products data array
- add "detail" event for Product details event

interdiff available.

mediamash’s picture

Good morning - could these be added to the next version of the module? Are there any plans for an update?

mediamash’s picture

@vasike After applying the patch succesfully, I can see it changed the files and added new ones, but nothing no rule is created. Can you export yours to make it work then?

mediamash2’s picture

@vasike

apparently no rule is created because it is not mentioned under .../commerce_google_tag_manager/contrib/commerce_google_tag_manager_example.rules_defaults.inc

Could someone extend the function commerce_google_tag_manager_example_default_rules_configuration() please ?

mediamash2’s picture

Status: Needs review » Needs work

no rule created - so not working

guruslot’s picture

Is it possible to track product impressions (Views) also?

guruslot’s picture

Does anybody have tried to implement Product impressions thru Views?

gauravkhambhala’s picture

The other rules are getting created from Commerce Google Tag Manager - Example module which is a sub module within this module. This patch doesn't contain changes to sub module and hence the rules are not being created automatically.

wizonesolutions’s picture

Tried this patch, but it doesn't work if products are being displayed directly. That admittedly makes some sense, but it doesn't work in my case. I'm going to try to add a Rules Action that works with /product/$product_id pages and add it to this patch. It's very similar, just that it will require the product directly and only take one argument (the product). I don't think the list makes sense for the default implementation. People can add that in an alter if needed.

wizonesolutions’s picture

Oh, fun! "Commerce Product is viewed" does not actually work since it's just generated from entity info. I'll have to check how we are rendering the actual page on our site and make a custom Rules event. I'll re-roll the patch then, but I'm not going to include a sample Rule. People can just clone one of the existing ones and fix it up, i.e. change the event to when a node of type (your product display) is viewed, and delete/change the action to the "product details" one. I'll leave in the product variation action I'm adding for edge cases like mine.

wizonesolutions’s picture

I think it works, but we're using a Commerce Panels setup. End result is the same in terms of the updated patch I'm going to attach once I'm done.

wizonesolutions’s picture

Status: Needs work » Needs review
FileSize
12.39 KB
7.62 KB

Here it is, with interdiff. It's basically like I said: no new rule, since our setup didn't facilitate that. I just call the "product variation" action directly. I didn't test the product display one, but it looks like it should work. As always, automated tests would be good, but I did not have the time to write them.

Someone might also want to add example rules for cases where this will work with Rules. This patch should also work with the latest dev.

apaderno’s picture

Issue tags: -Google Tag Manager, -Commerce Google Tag Manager