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 -->
|
<!-- 2. FACEBOOK PIXEL -->
|
||||||
<!-- ============================================== -->
|
<!-- ============================================== -->
|
||||||
<!-- Copie esse código e troque XXXXXXXXXX pelo ID do seu pixel 👇 -->
|
<!-- Meta Pixel Code -->
|
||||||
<!--
|
|
||||||
<script>
|
<script>
|
||||||
!function(f,b,e,v,n,t,s)
|
!function(f,b,e,v,n,t,s)
|
||||||
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
|
||||||
|
|
@ -104,13 +103,13 @@
|
||||||
t.src=v;s=b.getElementsByTagName(e)[0];
|
t.src=v;s=b.getElementsByTagName(e)[0];
|
||||||
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
s.parentNode.insertBefore(t,s)}(window, document,'script',
|
||||||
'https://connect.facebook.net/en_US/fbevents.js');
|
'https://connect.facebook.net/en_US/fbevents.js');
|
||||||
fbq('init', 'XXXXXXXXXX');
|
fbq('init', '1494357542144348');
|
||||||
fbq('track', 'PageView');
|
fbq('track', 'PageView');
|
||||||
</script>
|
</script>
|
||||||
<noscript><img height="1" width="1" style="display:none"
|
<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>
|
/></noscript>
|
||||||
-->
|
<!-- End Meta Pixel Code -->
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState } from 'react';
|
import { useState, type FormEvent } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { Check, ShieldCheck, Gift, ArrowRight, Loader2 } from 'lucide-react';
|
import { Check, ShieldCheck, Gift, ArrowRight, Loader2 } from 'lucide-react';
|
||||||
import { cn } from '../lib/utils';
|
import { cn } from '../lib/utils';
|
||||||
|
|
@ -15,7 +15,7 @@ export default function Offer() {
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
|
|
||||||
const handleCheckout = async (e: React.FormEvent) => {
|
const handleCheckout = async (e: FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (!email) {
|
if (!email) {
|
||||||
setError('Por favor, informe seu e-mail.');
|
setError('Por favor, informe seu e-mail.');
|
||||||
|
|
@ -25,6 +25,11 @@ export default function Offer() {
|
||||||
setError('Por favor, informe um e-mail válido.');
|
setError('Por favor, informe um e-mail válido.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fire InitiateCheckout parameter for Meta Pixel
|
||||||
|
if (typeof window !== 'undefined' && 'fbq' in window) {
|
||||||
|
(window as any).fbq('track', 'InitiateCheckout');
|
||||||
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
setError('');
|
setError('');
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useEffect } from 'react';
|
||||||
import { motion, useScroll, useSpring } from 'framer-motion';
|
import { motion, useScroll, useSpring } from 'framer-motion';
|
||||||
import Navbar from '../components/Navbar';
|
import Navbar from '../components/Navbar';
|
||||||
import Hero from '../components/Hero';
|
import Hero from '../components/Hero';
|
||||||
|
|
@ -24,6 +25,13 @@ export default function LandingPage() {
|
||||||
// Ativa o repasse automático de UTMs para links de checkout
|
// Ativa o repasse automático de UTMs para links de checkout
|
||||||
useUTMForwarder();
|
useUTMForwarder();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Fire ViewContent parameter for Meta Pixel
|
||||||
|
if (typeof window !== 'undefined' && 'fbq' in window) {
|
||||||
|
(window as any).fbq('track', 'ViewContent');
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
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">
|
<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
|
<motion.div
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,13 @@ export default function SuccessPage() {
|
||||||
|
|
||||||
if (sessionId || status === "approved") {
|
if (sessionId || status === "approved") {
|
||||||
setIsValid(true);
|
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 {
|
} else {
|
||||||
// Se não tiver nenhum parâmetro válido, joga de volta pra home
|
// Se não tiver nenhum parâmetro válido, joga de volta pra home
|
||||||
navigate("/", { replace: true });
|
navigate("/", { replace: true });
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue