Comments (9)
Hi @eugene-manuilov. As discussed, I have mentioned the usage of forwardRef
, and addressed other feedback. IB updated, thank you!
from site-kit-wp.
Huh, good catch!
The simplest solution would instead to wrap the components with
<div ref={ trackingRef }></div>
, within theDashboardTopEarningPagesWidgetGA4
, avoiding the use offorwardRef
entirely.
Which components would need wrapping exactly? We need Widget
/WidgetNull
to be the top-level components that are returned for the widget layout code to work, but if you need to wrap anything insight I don't have a problem with that. 👍🏻
from site-kit-wp.
QA Update ⚠️
- Tested on dev environment.
- Verified that
View_notification
and'click_learn_more_link'
events are getting trigger as per AC.
@benbowler Since #8049 has not been merged yet we are using the code snippet provided under QAB to load the widget. However, I have noticed that when users view the 'Top earning pages'
widget then event 'view_widget'
is not being triggered. . Could you please investigate whether the event is not being triggered because we are forcibly displaying it through the code snippet, or if it is actually an issue with the event not being triggered under any circumstances?
from site-kit-wp.
QA Update ✅
- Tested on dev environment.
- Verified that
View_notification
and'click_learn_more_link'
and'view_widget'
events are getting trigger as per AC.
from site-kit-wp.
@tofumatt do you mind adding an estimate to this ticket if possible?
from site-kit-wp.
- Using the
useRef
hook, add aref
to the renderedWidget
components (for bothWidget
components that rendersAdSenseLinkCTA
and the unconditionally rendered widget content).
@nfmohit, why not to implement event tracking in the CTA itself? The same way how we do it in the KeyMetricsCTAContent
component. In this case, we won't need to change the Widget
component.
In
assets/js/googlesitekit/widgets/components/Widget.js
:
- Accept additional (spread) props in the
Widget
component and pass any additional props passed intoWidget
to thediv.googlesitekit-widget
element.
If we really need this, then the component should be updated using the forwardRef
approach. https://react.dev/reference/react/forwardRef
- In the rendered
AdSenseLinkCTA
component, add anonClick
prop and track theclick_learn_more_link
event according to the ACs.
Let's expand this a little bit more and add more details to make sure that we have an agreement as to what we mean by "according to the ACs".
from site-kit-wp.
Ok, thanks. IB ✔️
from site-kit-wp.
I have been working on this today and have implemented it with one small addition to the IB; updating assets/js/googlesitekit/widgets/util/get-widget-component-props.js
to forward the ref through to the underlaying Widget
component.
However while testing this I found that if I scrolled down on the dashboard slowly the event would not trigger. It would only trigger if I scrolled to this section quickly, or clicked on "Monetization" then scrolled down from there. (I have a video I can share of this occurring I will share directly).
Debugging this a little, it seems the DashboardTopEarningPagesWidgetGA4
component does not get the updated node reference to the underlaying Widget
in this case as it's not rendered immediately and useRef does not trigger re-rendering when the underlaying node is created.
I could not repeat this bug with the /DashboardPageSpeed
widget.
I began looking at using useCallback
instead of useRef
, as in this React doc, to get the updated node, however this would not work with the useIntersection
hook so would required much additional work.
The simplest solution would instead to wrap the components with <div ref={ trackingRef }></div>
, within the DashboardTopEarningPagesWidgetGA4
, avoiding the use of forwardRef
entirely.
@tofumatt @eugene-manuilov, what is the best approach in your view?
from site-kit-wp.
I've tried wrapping the internals of both of the Widgets
with <div ref={ trackingRef }></div>
, however the same bug occurs. trackingRef
does not pass the correct dom element to IntersectionObserver
.
The way I could resolve this was to intercept the ref
function and force the DashboardTopEarningPagesWidgetGA4
component to re-render when it received the DOM element:
Over to CR now.
from site-kit-wp.
Related Issues (20)
- Extend `createSettingsStore()` to allow multiple usage within a module.
- Add `ga4AdSenseIntegration` feature flag HOT 4
- Remove `ga4AdSenseIntegration` feature flag to launch GA4 + AdSense integration feature HOT 4
- `clearError()` call is missing `baseName` in AdSense setup component HOT 4
- `useRefocus` hook does not trigger
- Error : Getting token failed when setting up Site Kit HOT 1
- Update the Consent Mode settings section if and when the WP Consent API is integrated with WP Core.
- Add GA event tracking for Consent Mode on the dashboard HOT 2
- Add GA event tracking for Consent Mode on the Settings page HOT 2
- Launch the Single Analytics Module HOT 1
- Update WP Consent API plugin detection to account for non-standard location
- Tracking opt-out snippet outputs even when `Exclude Analytics` setting is off HOT 2
- Create `Web_Tag` class for `Ads` module HOT 2
- Create `Ads` Module E2E Tests to Cover Basic Module Setup Flow HOT 2
- Improve zero data message for "Top recent trending pages" key metric tile HOT 7
- Tagmanager error:"Not found or permission denied." console error showing when user selects different tag manager a/c. HOT 1
- Move `tail` warning out of the WP debug log ignore list. HOT 3
- Release 1.122.0 HOT 3
- GA4 Property Resets After Every SiteKit Update HOT 1
- PHP Deprecated Errors and unable to complete plugin setup with PHP 8.2/8.3 & WordPress 6.4.2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from site-kit-wp.