Hi y'all,

I've done a number of searches and haven't been able to find this question already asked...

I have a simple, (in a single php file) URL Redirect in the form of a Wordpress plugin.

I already have a simple "define->function->echo" code for displaying the total hits/visits count for each URL redirect.

My question is, does anyone know of a "simple" way to expand on the total hits count and show the hits by date? While keeping everything all in the one PHP file? (everything I know of would require multiple files, folders, .js etc)

What I'd like, in addition to the "total" hits/views is to also have hits count broken out for "Today", "Yesterday", "Last 7 Days", "Last 30 Days" and a variable "date range".

Thanks in advance for any advice.

Below is the "define->function->echo" code I'm using to track the total hits per URL.

if($url != '') {
    hit_count($post->ID);
    header( 'Location: '.$url );
    exit();
}




function hit_count($post_id) {
    $count = get_post_meta($post_id,'redirect_count',true);
    if(!$count) {
        $count = 0;
    }

    $count = $count + 1;
    update_post_meta($post_id,'redirect_count',$count);
}




    $count = get_post_meta($post->ID,'redirect_count',true);
    if(!$count) {
        $count = 0;
    }
    echo '<br /><br />This URL has redirected <strong>'.$count.'</strong> times';
}
Member Avatar for LastMitch

@master-tech

I have a simple, (in a single php file) URL Redirect in the form of a Wordpress plugin.

I know you provide the code in PHP. But the question is more in the Internet Marketing Section than in PHP Section

I'm no familiar with SEO and other stuff in the Internet Marketing Section

Have you read this before:

http://support.google.com/webmasters/bin/answer.py?hl=en&answer=156449

There should be Wordpress plugin about SEO & URL regarding about your question.

@LastMitch thanks for your reply.

I am familiar with Googles robots.txt thread and I don't know how my question would relate to internet marketing or SEO.

I'm just looking for ideas on how to "simply" query & echo how many times a URL has been visited on specific dates.

Member Avatar for LastMitch

@master-tech

I'm just looking for ideas on how to "simply" query & echo how many times a URL has been visited on specific dates.

When you mention the word total hits/visits meaning visitor coming to your website. That's why I post that google link about visitors.

But you want a query to echo out the URL then you can used this

it's called a CURL Function, it redirected URL's:

http://php.net/manual/en/ref.curl.php

The function that you are looking for is this

it's called curl_getinfo this will redirected the count:

http://www.php.net/manual/en/function.curl-getinfo.php

YES!!.. awesome!

That must be what I'm looking for!

I was trying to use Date/Time and it was working out way too complicated for the simple stats I'm trying to display.

Thank you.

Member Avatar for LastMitch

@master-tech

Is this solved?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.