Jump to content
David Karich

Page Hit Counter – Simple Page View Tracking

Recommended Posts

David i like your module it works nicely. I have an issue using it in combination with amp pages.

With amp pages we are not allowed to inject any java script code. So I want to exclude my amp pages from getting the pagehitcounter.min.js injected. Is their a way to block this?

For the pages were I want to have the java script I can load it manually.

I know you can set templates from getting tracked and not tracked but my issue is that i don't have separate template for an amp page and the normal page

Share this post


Link to post
Share on other sites
7 hours ago, erikvanberkum said:

David i like your module it works nicely. I have an issue using it in combination with amp pages.

With amp pages we are not allowed to inject any java script code. So I want to exclude my amp pages from getting the pagehitcounter.min.js injected. Is their a way to block this?

For the pages were I want to have the java script I can load it manually.

I know you can set templates from getting tracked and not tracked but my issue is that i don't have separate template for an amp page and the normal page

Hey Erik, here's a suggestion how you can do it manually, at least for those templates that have an AMP version. But I haven't tested it.

  1. Remove the specific template from the "Templates for automatic tracking" configuration and
  2. Add this specific template in the "Templates for allowed API tracking" configuration
  3. In the non-AMP version of the template, you add the following data atrribute to the body tag, with the ID of the current page which should be tracked. For example: 
    <body data-phc="<?php echo $page->id; ?>">
  4. Now manually add the tracking script for the non-AMP version before the closing body tag. 
    <!-- For debugging use PageHitCounter.js -->
    <script defer src="<?php echo $config->urls->PageHitCounter; ?>PageHitCounter.min.js"></script>

That's it.

Share this post


Link to post
Share on other sites

Hi,

Page Hit counter stay always at 0

need help please

 image.png.b0f9c0980daa17d3918555ba199fb7dc.png

Share this post


Link to post
Share on other sites

Dear David Karich. Thanks a lot for this very nifty module.

However I have one issue on a multilanguage site. I want to count the phits on one template. I configured it in the module settings. For that template some pages work perfectly well. But for some other (same template), I see that the phits was counted on the debug console But it doesn't seem to be recorded in the database ( the phits remain at 0). These pages are not in the same language that those that work. I guess it has to do with the language but I have not yet figured out the use case.

Has anybody else used this module on a multi language site ? Any known issue in this contexte ?

Thanks in advance

Share this post


Link to post
Share on other sites

Hi @antpre,

I think the way this module store data does not support a multi language site.

Gideon

Share this post


Link to post
Share on other sites

@Gideon : tks for your answer. That's not a good news though. The module is realy well done with all the options available in the admin.

@David : any chance that you add support for multilanguage sites in the module's roadmap in the near future.

Thanks

Share this post


Link to post
Share on other sites

Hello everyone,

I realized that I might have not been precise enough with my question.

I have a multi language web site. I have a template called document. I have 4 language : default (not used on the front end), french and english and spanish

A page with that template can be either active  in french , in english, spanish or active in all of them. English in the not the default language though (it is the first additional language).

My need is to have page hit counts views irrespective of the language. and stores views irrespective of the language. so if a page gets 1 view in english and 1 view in french. It would count 2 views.

I tested my use case with Page hit module. I found that the views were properly recorded if the page was active english. But if the page is active in french or spanish the view is counted in the front end (on the debug consol it says 'Page Hit Counter: Tracked' but doesn't get recorded in the database.

Why would it work for the first language that is not the default language and not with the other one. For the purpose of my test I duplicated the same page so only the language active status was changed. The change of url (from /fr to /en) is not the problem cause the page that has both language get the counts recorded from both the url language.

I guess the module is not working in my use case even if I didn't need the recorded hits to be per se multilanguage.

Share this post


Link to post
Share on other sites
On 3/12/2020 at 12:02 PM, Wissem said:

Page Hit counter stay always at 0

Hi, I am seeing the same issue, how did you solve it?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By benbyf
      Hi, Looking to create form elements on a page–some input with a colection of form inputs and the appropriate labels and variables for that input. I've used ProForms in the past and rolled out my own when creating simply one off forms, but I wonder if anyone has found a good way of allowing form creation on page editing so that clients can adhocly make and edit forms?
      Thanks
    • By verdeandrea
      Hello,
      I am using ProCache v3.1.8 on ProcessWire 3.0.96.
      Everything worked fine in the past, but today I noticed that the css file serverd by procache gives a 410 error. 
      The file is there, I checked.
      I deleted the cached files, I deleted the css file, I looked into the .htaccess file looking for some clues about this problem but nothing worked.
      The only way i can see my website correctly again is disabling ProCache. 
      Has anyone any clue on what could be the cause of the problem or on what should I do to fix it?
      Thanks!
    • By Atlasfreeman
      Hi!
      I want to make a small site, a one page site.
      And i have this idea about doing 2 to 3 diffrent template that i can load into the index / home page.

      I want to do this with an array so that i can keep creating more topics (with the template) id needed.
      <?php include('./head.inc'); // include header markup ?> <?php $children = $page->get('template=onecolmn|twocolumn, sort=sort'); foreach($children as $child) { include($child); } ?> <?php include('./foot.inc'); // include footer markup ?>  
      As you can see i have to template wish i want to control from the backend.
      I know include does not work this way, put what is my other option to make an array that loads the whole page on an other pages.
       
       
    • By Liam88
      Hi All,
      New user over at Processwire and have been rebuilding my site based on this CMS.
      I have been able to find so many answers through Google but I'm a little stuck on this one.
      I have my services page -> services categories -> category children.
      An example of those would be - domain -> services -> ppc -> management
      I also have a set of tags which have different names - services-tag -> grow-your-traffic
      Under these tags I would have multiple links to pages such as ppc, seo, social media and so on.
      A second example would be - services-tag -> convert-your-traffic
      Under here i would have multiple links to pages such as CRO
      Now the set of tags are not visible on-site as they are only created to give overview content to the main services categories.
      Using the categories and the tags I am looking to produce a layout such as (i have also attached an image as an example:
      Tag_1 headline
      Pull all services categories linking to Tag_1
      Tag_1 snippet
      Tag_2 headline
      Pull all services categories linking to Tag_2
      Tag_2 snippet
      So far I have this snippet which is pulling in the tag content but unable to get the posts to show under each of the tags. 
      If i change the if and statement to "tags" instead of "tag" then all posts show under all tags. Where as i want it to show only the posts which are linked to that tag.
      <?php namespace ProcessWire; $tags = $pages->get("/categories-services/")->children(); // Gets the tags $posts = $pages->get("/services/")->children(); // Gets the services categories $link = $tags->ref_6; // Gets the tags and services categories link - under here you have pages_id (services cat id) and data (tags id) // Tag header and summary foreach($tags as $tag) { // This breaks down the tags into sections echo '<section id="services"> <div class="container"> <div class="row"> <h2 class="heading-1"><span>'. $tag->headline.'</span></h2> <p class="mb-5">'. $tag->summary.'</p> </div> <div class="row justify-content-around services">'; // Main services categories that link to the above tags if ($posts->id === $link->pages_id && $tag->id === $link->data){ foreach($posts as $service){ // This pulls in the services categories under the tag header. echo '<div class="card flex-card" id=""> <div class="card-img"> <a href="/'. $service->name.'" title="'. $service->name .'"> <img class="card-img-top" src="../assets/files/'. $service->id.'/'. $service->img_1.'" alt="'. $service->img_1.'" title="'. $service->img_1.'"></a> </div> <div class="card-body"> <h3 class="card-title">'. $service->headline.'</h3> <p class="card-text">'. $service->summary .'</p> <div class="card-action"> <a href="" title="'. $service->name .'" role="link" class="link">View service<span></span></a> </div> </div> </div> '; } } // Grey snippet text echo '</div> </div> </section> <div class="snip-2 light-grey"> <div class="container"> <div class="row text-center">'. $tag->get('grey') .'</div> </div> </div>'; } ?> I appreciate this is a long post but i'm trying to be clear as I appreciate everyone's time.
      Any insight into where I am going wrong is greatly appreciated.
      Liam



    • By Harmen
      I want to add a few pages to an AsmSelect Page field inside a repeater using the following code:
      $trialsPage = wire("pages")->get(28422); // Get the page $trialsPage->of(false); $newTrial = $ordersPage->trial_repeater_orders->getNewItem(); // Add item to repeater foreach ($selectedProducts as $selectedProduct){ $productPage = $pages->get("template=product, reference=$selectedProduct"); $newTrial->trial_selected_products->add($productPage); } $newTrial->save(); $trialsPage->save(); However, when I check the page where the field is located it doesn't have the new values as expected. The selected pages exist, the field is in the right location, made sure that the output formatting is turned off: $page->of(false); But it still doesn't work with a variable. No matter what I try, it doesn't work.
      It only works when I replace $selectedProduct with a hardcoded string. Am I doing something wrong here?
×
×
  • Create New...