Follow UTM to the next page!

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 it should follow and look something 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>
    
asked by anonymous 15.08.2017 / 15:25

0 answers