feat: adiciona meta pixel e eventos viewcontent, initiatecheckout e purchase
This commit is contained in:
parent
4037afcac4
commit
d87be4d434
4 changed files with 26 additions and 7 deletions
|
|
@ -93,8 +93,7 @@
|
|||
<!-- ============================================== -->
|
||||
<!-- 2. FACEBOOK PIXEL -->
|
||||
<!-- ============================================== -->
|
||||
<!-- Copie esse código e troque XXXXXXXXXX pelo ID do seu pixel 👇 -->
|
||||
<!--
|
||||
<!-- Meta Pixel Code -->
|
||||
<script>
|
||||
!function(f,b,e,v,n,t,s)
|
||||
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
||||
|
|
@ -104,13 +103,13 @@
|
|||
t.src=v;s=b.getElementsByTagName(e)[0];
|
||||
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
||||
'https://connect.facebook.net/en_US/fbevents.js');
|
||||
fbq('init', 'XXXXXXXXXX');
|
||||
fbq('init', '1494357542144348');
|
||||
fbq('track', 'PageView');
|
||||
</script>
|
||||
<noscript><img height="1" width="1" style="display:none"
|
||||
src="https://www.facebook.com/tr?id=XXXXXXXXXX&ev=PageView&noscript=1"
|
||||
src="https://www.facebook.com/tr?id=1494357542144348&ev=PageView&noscript=1"
|
||||
/></noscript>
|
||||
-->
|
||||
<!-- End Meta Pixel Code -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from 'react';
|
||||
import { useState, type FormEvent } from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Check, ShieldCheck, Gift, ArrowRight, Loader2 } from 'lucide-react';
|
||||
import { cn } from '../lib/utils';
|
||||
|
|
@ -15,7 +15,7 @@ export default function Offer() {
|
|||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
|
||||
const handleCheckout = async (e: React.FormEvent) => {
|
||||
const handleCheckout = async (e: FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!email) {
|
||||
setError('Por favor, informe seu e-mail.');
|
||||
|
|
@ -26,6 +26,11 @@ export default function Offer() {
|
|||
return;
|
||||
}
|
||||
|
||||
// Fire InitiateCheckout parameter for Meta Pixel
|
||||
if (typeof window !== 'undefined' && 'fbq' in window) {
|
||||
(window as any).fbq('track', 'InitiateCheckout');
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
setError('');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { useEffect } from 'react';
|
||||
import { motion, useScroll, useSpring } from 'framer-motion';
|
||||
import Navbar from '../components/Navbar';
|
||||
import Hero from '../components/Hero';
|
||||
|
|
@ -24,6 +25,13 @@ export default function LandingPage() {
|
|||
// Ativa o repasse automático de UTMs para links de checkout
|
||||
useUTMForwarder();
|
||||
|
||||
useEffect(() => {
|
||||
// Fire ViewContent parameter for Meta Pixel
|
||||
if (typeof window !== 'undefined' && 'fbq' in window) {
|
||||
(window as any).fbq('track', 'ViewContent');
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-pink-50 text-indigo-900 selection:bg-pink-300 selection:text-indigo-950 font-sans overflow-x-hidden">
|
||||
<motion.div
|
||||
|
|
|
|||
|
|
@ -16,6 +16,13 @@ export default function SuccessPage() {
|
|||
|
||||
if (sessionId || status === "approved") {
|
||||
setIsValid(true);
|
||||
// Fire Purchase parameter for Meta Pixel
|
||||
if (typeof window !== 'undefined' && 'fbq' in window) {
|
||||
(window as any).fbq('track', 'Purchase', {
|
||||
value: 9.99,
|
||||
currency: 'BRL'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Se não tiver nenhum parâmetro válido, joga de volta pra home
|
||||
navigate("/", { replace: true });
|
||||
|
|
|
|||
Loading…
Reference in a new issue