Support » Plugin: Google Analytics Post Pageviews » How to create cronjob for emptying the cache?

  • Resolved Angelos Kyritsis

    (@angelos-kyritsis)


    Hello,

    I would like to automatically empty the pageviews cache at specific times of the day.

    I already have the Cronjobs plugin installed, and I tried to create a cronjob, but it doesn’t work.

    What I have tried so far is adding the (my domain)/wp-admin/options-general.php?page=google-analytics-post-pageviews&reset URL as a “URL to Load”.

    Cronjob settings

    Is there any other way to add the reset as a cronjob, as a Script to include, Function to Run, or Custom PHP to Run that would work?

    • This topic was modified 2 years, 7 months ago by Angelos Kyritsis. Reason: pic didn't work
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author maximevalette

    (@maximevalette)

    Hi,

    You can run the following PHP code to remove the DB cache for GAPP:

    <?php
    $wpdb->query("DELETE FROM " . $wpdb->options . " WHERE option_name LIKE '_transient_gapp-transient-%'");
    $wpdb->query("DELETE FROM " . $wpdb->options . " WHERE option_name LIKE '_transient_timeout_gapp-transient-%'");
    
    set_transient('gapp-namespace-key', uniqid(), 86400 * 365);
    ?>
    

    Awesome, it worked. Mille merci!

    Plugin Author maximevalette

    (@maximevalette)

    You’re very welcome 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create cronjob for emptying the cache?’ is closed to new replies.