Is it possible to know which website my link was clicked on?

Asked

Viewed 1,236 times

0

I have a link from my site on some other sites and would like to know if it is possible to know which site it was clicked on, informing me the site url for example. And if possible, how do I do that? which language? if possible with php? From now on, thank you.

3 answers

2

For now yes - if the user clicks a link that leads to your page, with some restrictions, the URL of the previous page is sent to your server in the HTTP header.

And in this case, the contents of this header will be available within PHP code as $_SERVER['HTTP_REFERER'].

If the server-side technology is not PHP, or you are manipulating the "raw" HTTP, the header name is simply referer (the correct word in English would be referrer, but this comes from the beginnings of the web, and did wrong even).

The header documentation can be seen here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer . In particular: if the previous page were with the protocol file:// or data, the referrer is not passed. If the previous page were http and your for https the referrer is not past either.

Why "for the time being"? Why browser producers are aware that this type of information from the margin to many privacy disruption situations - and it may be that in the coming months the restrictions for sending this header in major browsers will increase nicely.

A long-term solution, and more correct, is to generate custom links to each partner site - with a chunk of data that matches an object in your database: that way you’ll always know which link was used and you can associate as much information as you want with each link.

As to which site the navigation came from in front-end code, in Javascript:you can use document.referrer, which is filled with the same information. Although browsers have the property document.history and the object History, these objects do not reveal history Urls to non-privileged code (any code running on a web page). It is possible to use these objects to send the user back "to where he came from", using the method back() - but the only way Javascript code knows where the navigation came from is if the server-side application picks up the header content referer and place it in the page template (or serve it as web-service).

I haven’t checked examples or documentation, but I assume that Javascript code written in browser extensions is "privileged" and may have explicit access to the content of document.history.

0

I will not know how to post a better solution than the ones mentioned below, but in a hosting that I have to know where the links come from in each place that I posted I put in the URL itself, that’s why there are several direct links to some pages. On site1:

http://meusite.com/meudiretorio/?get=meulink&ref=http://www.algumblog.com

On site2:

http://meusite.com/meudiretorio/?get=meulink&ref=http://www.algumforum.com.br

Hence the PHP that will capture the information:

<?php
if(isset($_SERVER['HTTP_REFERER'])){
   $ref =  $_SERVER['HTTP_REFERER'];
}else{
   if($_SERVER['REQUEST_METHOD'] == 'GET'){
      $ref = $_GET['ref'];
   }else{
      $ref = "Sem referencia!";
   }
}
/* Após verificação da referencia */
echo $ref;
?>

The variable GLOBAL $_SERVER['HTTP_REFERER'] must be considered first because the link with the reference may have been copied by another person and replaced on another site.

If you find strange or "ugly", you can put the reference in BASE64:

On site1:

http://meusite.com/meudiretorio/?get=meulink&ref=aHR0cDovL3d3dy5hbGd1bWJsb2cuY29t

On site2:

http://meusite.com/meudiretorio/?get=meulink&ref=aHR0cDovL3d3dy5hbGd1bWZvcnVtLmNvbS5icg==

So remember to decode on the line if you use the GET method:

$ref = base64_decode($_GET['ref']);

-1

Link your site with a Google Analytics account, enter in the source code the piece of code where your site will be monitored by it, and after 24 hours you will have access to the resources to know the sources where the clicks came from, which websites and much more information.

Google Analytics is a very useful tool for marketers. In this post, let’s show how a correct analysis of the data makes all the difference! Google Analytics is one of the key partners of any marketer and that’s no secret to anyone. But knowing how to use this tool in a strategic way, and not only as a data source, requires much more knowledge.

More than a set of numbers and statistics, a good analyst should know how to understand where website traffic is coming from, how users are behaving and what is the most common visitor flow within pages, for example.

However, as we know, Google Analytics is not that simple a tool. It is very common to have doubts at the time of better understanding the metrics and results.

For example, do you know what Direct Traffic from your blog means? This is one of the most frequent questions that we see here in Rock Content and, so, we decided to produce this content to remove this doubt once and for all. Come on?

What is Direct Traffic? By definition of Google Analytics (GA) itself, a direct session is that traffic that does not have a very well defined origin.

That is, Analytics can not always identify what is the real origin of the traffic of your site, classifying as Direct Traffic what was really traffic of social networks or ads, for example.

When does a Direct session take place? By default, some of the main sources of Direct Traffic are when a user types their website’s domain (www.marketingdecontenteudo.com, for example) directly into the browser or even had already marked their website in the browser’s bookmarks session to easily access.

However, as we said before, Direct Traffic also encompasses a larger number of visits, which goes beyond these two situations shown.

Basically, direct sessions occur at any time when Google Analytics can’t identify another source of traffic. Some of these situations are:

Clicks on email links (depending on the user’s email provider); Click on links in Microsoft Office or PDF documents; Site access from shortened links (depending on the link shortener used); Click on mobile app links from social networks such as Facebook and Twitter. Mobile apps usually don’t pass on correct source information; Access to a "unsecured" website (http protocol), coming from a "secure" website (https protocol), since the secure website does not pass the traffic source information to the unsecured website. For example, if someone clicks a link on the page https://empresa1.com to go to a page http://empresa2.com, Company 2’s GA will show this session as Direct Traffic; Campaigns on social networks, email marketing, paid ads, or any other form of linking where the URL is not with the source parameters set correctly can be read as Direct Traffic; Direct Traffic Experiment An interesting experiment was done by Groupon to understand what was the percentage of sessions that were dealt with as Direct Traffic but, in fact, came from Organic Traffic.

A test was made in which those responsible for the site used the Google Search Console to "unindexe" the Google site for a few hours, IE, the domain would not appear when users did some search, even when the pages of the site were already indexed in the first positions.

The conclusion of the experiment was that about 60% of the Traffic that GA reads as Direct is actually Organic Traffic that was not interpreted correctly by Analytics - based only on long URL pages.

This is a very bold and extreme test, so we do not recommend that you do this on your website. However, we can use this experiment as a basis for comparison.

To learn more about the experiment and the methodologies used, read here the full report of Gene Mckenna, Product Director at Groupon.

How to Fix Your Direct Traffic Reading As you can see so far, the exact origins of Direct Traffic are still a mystery to marketers. However, there are some ways to minimize these GA read errors.

Check out some of them below!

Use identifier parameters in your campaign Urls For specific campaigns, such as triggering emails or social ads, for example, you can add parameters to your site’s target Urls to ensure that Analytics reads that traffic with the source sources correctly.

The easiest way to build a URL with parameters correctly is by using the Campain URL Builder, where you can select the information as you want it to be read by GA.

Stay tuned for sudden changes in your site’s traffic sources Marketers are already used to tracking traffic acquisition channel reporting (in the Acquisition report > All traffic > Channels).

So one of the best ways to understand when your GA is reading Direct Traffic improperly is by looking for drastic changes across all channels - and not just Direct Traffic.

We know that Analytics may interpret some sessions as "Direct Traffic" improperly.

If you notice that References (Referral) or Organic traffic, for example, have significant changes at the same time as Direct Traffic, it may be that there has been some change in the reading of visits.

Source: https://marketingdeconteudo.com/trafego-direto-no-google-analytics/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.