Google Analytics for Kirby. Set it and forget it. Only Google Analytics ID required as a setting.
<?php echo ga(); ?>
Features
Load script only for not logged in users.
Load script only if not on a localhost enviroment.
Possible to disable the script completely.
Possible to debug and always load the script.
Possible to change the script template/snippet path.
Possible to change the IP blacklist.
Install
Add ga folder in site/plugins/.
Set Google Analytics id to your config.php. See options.
Add <?php echo ga(); ?> in your footer snippet.
Options
ID (required)
The Google Analytics ID is required for the script to work.
c::set('plugin.ga.id', 'UA-12345678-12');
Active
You can deactivate the script by setting this value to false.
c::set('plugin.ga', true);
Debug
The script is only active for not logged in users that are not on a localhost environment. If you always want to have the code active, set this value to true.
c::set('plugin.ga.debug', false);
Template path
If you donāt like the script and want to change it, change the template path. You have access to $ua, $page, $pages and $site in the template.
A snippet is used instead of a function in the footer.
Removed option plugin.ga.template.
Added option plugin.ga.snippet.
Adds <-- Kirby GA --> if script does not run (on localhost for example).
The main reason for this plugin is to try to never run Google Analytics when you build your site. The script will therefor not run for logged in users and users on localhost. There is an IP blacklist as well.
There are tons of things that can be added to the script and I canāt cover them all. Therefor I made it as a snippet with the latest version of the plugin.
You can override the snippet by simply create your own snippet in your snippets folder called ga. If you donāt like the snippet name you can change it in the config.php:
@novacanye What youāre looking for is a bit beyond my current target. Iām about to create a basic GA integration with only some dashboard widgets. An extended widget generator is not impossible but a lot of work⦠Let me think about it.
Iām planning a to provide a beta release in early May.
The installation instruction in the first post arenāt very clear and donāt match the instruction on GitHub.
What does that mean exactly? What āgaā folder? Where do you get that āgaā folder?
As you mentioned further down with your 0.2 release post, this code is now outdated, but anyone using Google or just searching the forum will more likely just read the first post.
The installation instructions in the GitHub repo are much clearer, but one also has to find them first.
For this and other plugins, I recommend to follow the original source, which for most plugins is a Github repository. This forum is a great way to promote and discuss plugins, but itās not the original source.
Keeping the documentation updated in the forum means keeping two places up to date, the forum and the repository. Also, because the post is no longer editable after a specific time, I canāt keep it up to date without PM one of the crew members each time.
But because you had this problem, Iāve learned that we should probably never write installation instructions or details about the plugin in the forum, only more general features, images, videos but not exactly how to use them, because it might change over time.
Hello! I am having trouble receiving any hits on the Google Analytics dashboard after I followed your Github tutorial.
Is <?php echo snippet('ga'); ?> what we are supposed to include in the footer snippet?
Hi, thanks for the help!
I am not on localhost, and I have added the GA id.
However I am a bit confused with the ālogged inā part.
On the Github repo it says: Doesn't run the GA script if you are logged in.
In your response above you suggest I should be logged in, if I understand correctly.
Can you clarify?