1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-22 17:23:50 +01:00
This commit is contained in:
Matthias Kretschmann 2020-03-12 05:36:36 +01:00
parent 4ac25229a5
commit a3f561264a
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -2,26 +2,16 @@ import React from 'react'
import styles from './Ad.module.scss' import styles from './Ad.module.scss'
import { useSiteMetadata } from '../../hooks/use-site-metadata' import { useSiteMetadata } from '../../hooks/use-site-metadata'
interface WindowWithMatomo extends Window {
_paq?: any
}
export default function Ad() { export default function Ad() {
const { ad } = useSiteMetadata() const { ad } = useSiteMetadata()
function handleClick(e: React.MouseEvent) {
e.preventDefault()
const { _paq } = window as WindowWithMatomo
_paq && _paq.push(['trackEvent', 'Ad Interaction', 'click'])
window.open(ad.link)
}
return ( return (
<a <a
className={styles.ad} className={styles.ad}
href={ad.link} href={ad.link}
onClick={(e: React.MouseEvent) => handleClick(e)} data-track-content
data-content-name="Text Ad"
data-content-piece={ad.title}
> >
{ad.title} {ad.title}
</a> </a>