S
S
symply_rabbit2018-06-14 15:40:08
PHP
symply_rabbit, 2018-06-14 15:40:08

How to save the path from contextual advertising on all pages of the site?

good afternoon! please tell me how to make a person who switched from Google contextual advertising, for example, walk around the site, but /?gclid=... would be saved in the url, no matter what folder of the site he looked into?
wrote the code

<?

if (!empty($_REQUEST['gclid'])) {
$IGOG=$_REQUEST['gclid'];
session_start();
$paramsession2=$IGOG;
$_SESSION[$paramsession2] = $IGOG;
?>

<?
if(strpos($_SESSION[$paramsession2]) !== false){
?>

<span>Вы перешли с контекстной рекламы</span>
<?
        }

}

Works on the main page. and you go to others - there is no inscription and there is no gclid in the url of this section

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2018-06-14
Hrebet @hrebet

$(document).ready(function() {
  var params = window.location.search.replace(/\+/g, '%20'); 
  $('a').each( function(i) {
    if (this.href.indexOf('?') == -1) {
      this.href = this.href + params;
    } else if (params.length) {
      this.href = this.href + '&' + params.substr(1);
    }
  });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question