Tracking Unique Visitors Only

Tracking unique visitors only?

The simplest method would be cookie checking.

A better way would be to create an SQL database and assign the IP address as the primary key. Then whenever a user visits, you would insert that IP into the database.

  1. Create a function included on all pages that checks for $_SESSION['logged'] which you can assign whatever 'flag' you want.
  2. If $_SESSION['logged'] returns 'false' then insert their IP address into the MySQL database.
  3. Set $_SESSION['logged'] to 'true' so you don't waste resources logging the IP multiple times.

Note: When creating the MySQL table, assign the IP address' field as the key.

<?php 
session_start();
if (!$_SESSION['status']) {
$connection = mysql_connect("localhost", "user", "password");
mysql_select_db("ip_log", $connection);

$ip = $_SERVER['REMOTE_ADDR'];
mysql_query("INSERT INTO `database`.`table` (IP) VALUES ('$ip')");

mysql_close($connection);
$_SESSION['status'] = true;
}
?>

Best method of tracking users for unique visitor reporting using .NET?

Firstly, unique users is always an approximation. There is no guaranteed way to force cookies, their persistance is not completely in your control anyway, and IPs often represent blocks (sometimes vast) of users. Data quality is not good in this area, you just have to accept that.

This is a good primer on cookie analytics.

In my experience tracking IPs does at least offer a safe lower bound, but you're still talking about vague data.

All other cookie alternatives I'm aware of are transient only.

Secondly, what do you mean by "JavaScript is not an option"? ASP.NET functionality is (imho) severely curtailed by turning JS off, and your options will be more limited. Is that the state you're expecting?

Can you count unique visitors to a website without server side code?

Like it has been said, you need a third-party tool (like Google Analytics) since any workaround done in the front-end part will be related to the client/browser-side, then you'll lose the tracking if a user changes the device for example.

You can easily install Analytics with some of the available plugins (like gatsby-plugin-google-gtag). This is recommended since under the hood uses gtag.js instead of analytics.js, which is what Google recommends due the last API changes.

To use is just install it by:

npm install gatsby-plugin-google-gtag // or yarn add gatsby-plugin-google-gtag

And add your configurations:

// In your gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-google-gtag`,
options: {
// You can add multiple tracking ids and a pageview event will be fired for all of them.
trackingIds: [
"GA-TRACKING_ID", // Google Analytics / GA
],
// This object gets passed directly to the gtag config command
// This config will be shared across all trackingIds
gtagConfig: {
optimize_id: "OPT_CONTAINER_ID",
anonymize_ip: true,
cookie_expires: 0,
},
// This object is used for configuration specific to this plugin
pluginConfig: {
// Puts tracking script in the head instead of the body
head: false,
// Setting this parameter is also optional
respectDNT: true,
// Avoids sending pageview hits from custom paths
exclude: ["/preview/**", "/do-not-track/me/too/"],
},
},
},
],
}

You can ignore the options you don't need.

Google analytics campaign unique visitors

You could look at the data in terms of unique landing page visits instead of sessions. This will give you unique pageviews.

To do this, create a custom segment for your source/medium/campaign, then navigate to Behavior > Site Content > Landing Pages.

Here you can view unique pageviews to your campaign's landing page.



Related Topics



Leave a reply



Submit