Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent Category disappeared from GA, attributing all events now to "not set" category #58

Closed
heymynameisdina opened this issue Aug 4, 2021 · 8 comments
Labels

Comments

@heymynameisdina
Copy link

Question

I've read through documentation, as well as other user issues and PRs and am not able to find the answer if you could please help. As of June 15, our previously properly working IA events started attributing all events to the category "not set".

Previous events (with accurate data):
Screen Shot 2021-08-03 at 7 05 25 PM

Current events (with inaccurate data):
Screen Shot 2021-08-03 at 7 05 36 PM

At some point, the Parent Category dropped off of our category label here. You'll see in the accurate events, each event has the Parent Category with a pipe prior to our custom category labeling. I believe that is being done on your end here. For some reason that is now missing and all of our events live in the "not set" category.

Additional context

Instant Analytics 1.1.12
Craft CMS 3.6.16
Craft Commerce Pro 3.4.0

We recently upgraded from Craft 2 -> 3 if that is relevant!

@khalwat
Copy link
Contributor

khalwat commented Aug 4, 2021

I'm guessing the upgrade from Craft 2 to Craft 3 is very relevant, as it'd result in a large number of changes to the website.

So the initial screenshot is data coming from a Craft 2 site running a Craft 2 version of IA, and the second screenshot is from Craft 3 site running the Craft 3 version of IA?

@heymynameisdina
Copy link
Author

heymynameisdina commented Aug 4, 2021

Thanks for the quick response, Andrew. Apologies here, I had our versions wrong. On June 23rd, we updated the following:

Craft: 3.5 to 3.6
Commerce 3.2 to 3.3

Our GA events transitioned to that second screenshot on June 16, however.

The only other thing I'm seeing remotely related to IA on our end -> We had made some recent adjustments to how we generate those category breadcrumbs (Audio/Headphones & Earbud Cases), but I've validated that the expected values are the ones that are being sent. Meaning we populate and send Audio/Headphones & Earbud Cases and that's exactly what's showing up in GA. While we're building them differently than before, we're sending the same exact information we did prior to June 16.

The only difference I'm seeing is the missing parent category and pipe prefixed in GA...can you confirm that the parent category and pipe are generated on the IA side? I'm not seeing anywhere in our codebase that is now or was previously producing that prefix. Thank you again for your help!

@heymynameisdina
Copy link
Author

hey @khalwat can you confirm that the Top Level Category and Pipe prefix are automatically applied by Instant Analytics? That seems to be the missing piece here...

@khalwat
Copy link
Contributor

khalwat commented Aug 13, 2021

I'm not sure how this could change, but Instant Analytics does have a Product Category that you can set either in the config.php or in the plugin settings, which is where you choose the field in the Commerce Product that you use for the category.

Can you check on that?

@hahnzilla
Copy link

One related issue (can open post this elsewhere if you prefer) here is that it looks like if you select a single category in a hierarchical structure it formats it with a pipe and slash. For example:

Screen Shot 2021-08-30 at 3 28 02 PM

is formatted as Audio|Audio/Headphones.

Only reason I brought it up here is that I think Audio| shouldn't be present. Believe that's going to throw off the hierarchy in analytics:

The category to which the product belongs (e.g. Apparel). Use / as a delimiter to specify up to 5-levels of hierarchy (e.g. Apparel/Men/T-Shirts).


But for what it's worth, I did validate that Instant Analytics is passing a category through

@hahnzilla
Copy link

alright hey I believe I figured out the issue with instant analytics not setting the category. In our codebase, we're eagerloading the category on a purchasable's products in an event listener for later on in the lifecycle. It looks like instant analytics is specifically looking for a CategoryQuery in pullDataFromField.

You can replicate the issue by adding this event listener and then trying to add an item to the cart:

        Event::on(
            LineItemsService::class,
            LineItemsService::EVENT_POPULATE_LINE_ITEM,
            function ($event) {
                $product = $event->sender->purchasable->product;

                Craft::$app->getElements()->eagerLoadElements(
                    Product::class,
                    [$product],
                    [
                        'mainProductType' // category field
                    ]
                );
            }
        );

this isn't exactly how we're doing it, but seemed like the easiest way to show the issue

@khalwat
Copy link
Contributor

khalwat commented Sep 21, 2022

Yep, it's this that causes it to exit early:

            // If the source field isn't an object, return nothing
            if (!is_object($srcField)) {
                return $result;
            }

ref:

// If the source field isn't an object, return nothing

Probably it should handle the case where it is an array, due to eager loading.

khalwat pushed a commit that referenced this issue Sep 21, 2022
khalwat pushed a commit that referenced this issue Sep 21, 2022
@khalwat
Copy link
Contributor

khalwat commented Sep 21, 2022

Addressed in: b8b25c8 & 92a6fb2

Craft CMS 3:

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

    "nystudio107/craft-instantanalytics": "dev-develop as 1.1.18”,

Then do a composer clear-cache && composer update

…..

Craft CMS 4:

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

    "nystudio107/craft-instantanalytics": "dev-develop-v4 as 4.0.2",

Then do a composer clear-cache && composer update

@khalwat khalwat closed this as completed Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants