1
Hello
I have a code that when the button is clicked the URL parameter of the current page goes to the next page...
This would be the current URL:
google.com?utm_source=1
When the button is clicked should follow and be more or less like this:
facebook.com.br/?utm_source=1
Code:
<script>
jQuery(function(){
// variavel que recebe a classe do botao
$class = '.lp-pom-button';
var query = location.search.slice(1);
var partes = query.split('&');
var data = {};
partes.forEach(function (parte) {
var chaveValor = parte.split('=');
var chave = chaveValor[0];
var valor = chaveValor[1];
data[chave] = valor;
});
jQuery( $class ).each(function(i, item){
if(data['utm_source'] != undefined){
var link = jQuery(this).attr('href');
jQuery(this).attr('href', link+_self);
}
});;
});
</script>
Do you get an error running? Obs: I noticed that at the close of the
jQuery( $class ).each(function(i, item){
has two;
– rLinhares