Google Analytics code code example

Example 1: set up google analytics

How to set up Google analytics:

Watch this video: https://www.youtube.com/watch?v=lZf3YYkIg8w

Or Click on this link: https://support.google.com/analytics/answer/1008015?hl=en

Example 2: where to add google analytics code

The Google Analytics tag should be added near the top of the <head> tag and 
before any other script or CSS tags

Example 3: google analytics kirby

Yes, like this:

<?php if(!cookie::exists('accepted')) {
  cookie::set('accepted', 'true', 1440);
}
?>

This code checks if the cookie with the name “accepted” has already been set, if not, the cookie is set with the value “true” and a lifetime of 24 hours. For more options, see the docs.

You can check if the cookie has been set with

<?= cookie:get('accepted') ?>

Hope this helps.

Tags:

Misc Example