Page 1 of 1
Sharing click stats between sites
Posted: Mon Jun 11, 2018 12:18 pm
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.
Re: Sharing click stats between sites
Posted: Mon Jun 11, 2018 1:28 pm
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
to for example
and you would then use this code for that website
Code: Select all
<script>ccount_display('second_526')</script>
Re: Sharing click stats between sites
Posted: Tue Jun 12, 2018 6:27 pm
by ualhalla
Thanks a lot. This should get the job much easier.
Re: Sharing click stats between sites
Posted: Thu Jun 14, 2018 1:18 pm
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.
Re: Sharing click stats between sites
Posted: Thu Jun 14, 2018 3:23 pm
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).
Re: Sharing click stats between sites
Posted: Thu Jun 14, 2018 7:05 pm
by ualhalla
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.
Re: Sharing click stats between sites
Posted: Fri Jun 15, 2018 11:44 am
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.
Re: Sharing click stats between sites
Posted: Fri Jun 15, 2018 11:50 am
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.
Re: Sharing click stats between sites
Posted: Fri Jun 15, 2018 7:02 pm
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.