Creative Juices Bo. Co.

Satisfy Your Thirst For Something Refreshing!

Get Hit Count On Multiple Domains Using CJ Hitman

CJ Hitman Tip & Trick

One of my clients is using the CJ Hitman link manager script I created to track various links on their website. They use about 15 domains that point people to different areas of their site and they we're curious if they could use the information gathered through the script to determine the total hit counts for each domain.

We sure can. CJ Hitman is recording the entire path, so all we need to do is perform a little SQL QUERY magic to group the results for the domains.

<cfquery datasource="#APPLICATION.DSN#" name="GetHits">
   SELECT id, link, COUNT(hits) AS total_hits, IF(INSTR(link,'/')>0,Left(link,INSTR(link,'/')-1),link) AS domain
   FROM tblbloghitman
   GROUP BY domain
   ORDER BY total_hits Desc

Basically, all we are doing is trying to determine if the stored "link" contains a "/" path seperator. If it is, then we take it's position and find the left portion of the string up to that index number. If not, then we know that the stored "link" is the domain. We cast this result as the "domain" variable, which can then be used to group all those results.

Sheesh, I hope that makes sense. Well, trust me, it works. Let me know if you have any problems.