Sharing click stats between sites

Post your Click counter digestion problems here
Post Reply
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Sharing click stats between sites

Post by ualhalla »

Hello.

I'm just wondering if I can share the click stat between two websites?

It's like this: the counter is installed on the first website. The second website will also contain some of the contents of the first website. Is it possible to show the click stat directly from the first website to the second website?

I already tried linking the "display.php" file from the first website but nothing happens. What I did just to show the click stats on the second website is by backing up the database from the first site and restoring it to the second site every week. I wish there's a much easier way.

Thanks.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Sharing click stats between sites

Post by Klemen »

Interesting question.

With default files it doesn't work because the settings and functions are overwritten by each new display.php you load.

I prepared a modified display file that should work on remote websites.

To make this work:
1. Upload the display_remote.php file to each copy of CCount
2. On the first website, first import the local display.php, just like in the instructions:

Code: Select all

<script src="http://first.com/ccount/display.php"></script>
3. after that code, include display_remote.php from the second website:

Code: Select all

<script src="http://second.com/ccount/display_remote.php"></script>
4. now you can display any count from the second website by prefixing ID with "remote_". So, to show count on link with ID 526 from the second website, the code is:

Code: Select all

<script>ccount_display('remote_526')</script>
That should do it.

If you have more than one remote website, you should edit the display_remote.php file on each website and give IDs a unique prefix by changing

Code: Select all

$prefix = 'remote_';
to for example

Code: Select all

$prefix = 'second_';
and you would then use this code for that website

Code: Select all

<script>ccount_display('second_526')</script>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Re: Sharing click stats between sites

Post by ualhalla »

Thanks a lot. This should get the job much easier.
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Re: Sharing click stats between sites

Post by ualhalla »

Hello.

I followed the instructions but unfortunately, it doesn't work. The page on the second website now contains these scripts in the heading:
<script src="http://redist.ezyro.com/cnt/display.php"></script>
<script src="http://mimic.ezyro.com/c/display_remote.php"></script>

I uploaded "display_remote.php" to where "display.php" is located on both websites. I now display the click count with this as you instructed:
<script>ccount_display('remote_180')</script>

Nothing happens. The click stats disappeared. Anyway to fix it?

Thanks.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Sharing click stats between sites

Post by Klemen »

That's because you don't have a link with ID 180 in your http://mimic.ezyro.com/c/ counter (max ID is 179).
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Re: Sharing click stats between sites

Post by ualhalla »

Klemen wrote: Thu Jun 14, 2018 3:23 pm That's because you don't have a link with ID 180 in your http://mimic.ezyro.com/c/ counter (max ID is 179).
Yes, because ID 180 is on redist and I haven't added it yet on mimic. I want to fetch it from redist and display the click count on mimic. If that's the case, it still won't work because all the ID on redist need to be on mimic. Then I still have to backup and restore the database from redist to mimic. I think there's no way to fetch the IDs from redist and display the click count on mimic.

Oh well, back to the usual backup and restore thing. Thanks.
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Re: Sharing click stats between sites

Post by ualhalla »

I think the variables in display.php are local only to the site and can't be passed on to another site just like with the variables in a function in JavaScript which can't be used in another function. I wish there's another way of fetching the counts from a remote site.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Sharing click stats between sites

Post by Klemen »

My example above does just that; the display_remote.php passes variables from one site to another one for use within that site's function.

If you need some specific way to pass variables (not in the format CCount uses) it will be up to you to properly format and use them, or hire a PHP developer for help.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
ualhalla
Posts: 6
Joined: Mon Jun 11, 2018 11:54 am

Re: Sharing click stats between sites

Post by ualhalla »

Finally fixed it. Thanks for the display_remote.php file you created. The display_remote.php file is no longer needed on the page. By uploading the file to both sites, it somehow automatically passed on the variables for the counter. On the second site, instead of putting its own display.php script, I replaced it with the display.php script of the first website and that did the trick. The pages on the second website can now display the click stats from the first website. Also, the "remote_" prefix doesn't needed to be added on the ID because it will not work.

That file you created is the savior. Thanks again.
Post Reply