Speak up!
I need to do an event upload prevention of analitycs in the following scenario:
I have a form that when the submit is given, the post is rendered in ajax and this ajax returns a URL in which I do the redirect via location.href
. This other page where you receive the targeting has the code snippet where you send the event to Google. What happens is that every time the F5 user or directly enters the link, the event is being counted, giving wrong results in Analitycs reports.
Here's an example:
Source Page:
<form id="form">
<input type="text" name="teste" />
<button>Processar</button>
</form>
Landing page:
<script>
// preciso prevenir esse envio quando usuário der F5 ou entrar na página sem passar
// pelo form
ga('send', 'event', 'Teste', 'view', '<?php echo $_GET['varTeste'] ?>');
</script>
Script that does the redirect:
$( "#form" ).submit(function() {
// ajax na qual retorna o link
url = 'teste.php?varTeste=123';
location.href = url;
});