Skip to content

Commit

Permalink
send inline ad display event
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Mar 13, 2024
1 parent 3d0da0c commit b8bb039
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/src/modules/components/AdDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ const Root = styled('span', { shouldForwardProp: (prop) => prop !== 'shape' })((
export default function AdDisplay(props) {
const { ad, className, shape = 'auto' } = props;

React.useEffect(() => {
// Avoid an exceed on the Google Analytics quotas.
if (Math.random() < 0.9 || !ad.label) {
return;
}

window.gtag('event', 'ad', {
eventAction: 'display',
eventLabel: ad.label,
});
}, [ad.label]);

/* eslint-disable material-ui/no-hardcoded-labels, react/no-danger */
return (
<Root shape={shape === 'inline' ? 'inline' : adShape} className={className}>
Expand Down

0 comments on commit b8bb039

Please sign in to comment.