feat: use gtag instead gtm (#1695)
This commit is contained in:
parent
b5dd948e56
commit
2e588ae221
12 changed files with 64 additions and 34 deletions
|
|
@ -15,7 +15,7 @@ type Props = {
|
|||
isPlain?: boolean
|
||||
isShort?: boolean
|
||||
onClick?: () => void
|
||||
gaEventName?: string
|
||||
loc?: string
|
||||
}
|
||||
|
||||
const PlainBtn = ({ className, onClick }: { className?: string; onClick: () => void }) => {
|
||||
|
|
@ -40,18 +40,27 @@ const UpgradeBtn: FC<Props> = ({
|
|||
isShort = false,
|
||||
size = 'md',
|
||||
onClick: _onClick,
|
||||
gaEventName,
|
||||
loc,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const { setShowPricingModal } = useModalContext()
|
||||
const onClick = () => {
|
||||
if (gaEventName)
|
||||
(window as any).dataLayer.push({ event: gaEventName })
|
||||
const handleClick = () => {
|
||||
if (_onClick)
|
||||
_onClick()
|
||||
else
|
||||
(setShowPricingModal as any)()
|
||||
}
|
||||
const onClick = () => {
|
||||
if (loc && (window as any).gtag) {
|
||||
(window as any).gtag('event', 'click_upgrade_btn', {
|
||||
loc,
|
||||
event_callback: handleClick,
|
||||
})
|
||||
}
|
||||
else {
|
||||
handleClick()
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlain)
|
||||
return <PlainBtn onClick={onClick} className={className} />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue