1

We are running site over PHP WordPress. We also have website ads in Google adwords. When some user clicks on the ad, it lands on one of the page on website. On that page, I would like to know if the user came to page by clicking Google adwords or by some other way.

Is there any way I could do this? What should I check when user lands on the webpage? (Referrer etc.)

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • you can check your referer first `https://stackoverflow.com/questions/1864583/get-original-url-referer-with-php` then make an if else conditional based on your purpose. If rerefer adwords do something else do another thing – rheeantz May 23 '17 at 13:22

1 Answers1

4

When you create your Google AdWords campaign, use a special click url, containing a query string that you can verify. Like this:

https://your.domain/page.php?from=adwords

Then, checking it can be done on the server-side by inspecting the query string parameters, like this:

<?php
    if ($_GET['from'] == "adwords") {
        /* do special stuff, like store things in a database */

        /* Finally, maybe redirect them to some other page, if necessary */
        header('Location: /');
    }
?>
Anders Marzi Tornblad
  • 18,896
  • 9
  • 51
  • 66