Last active
January 29, 2023 16:34
-
-
Save mskian/de5ac2a143c558edad1e7d68be2a423f to your computer and use it in GitHub Desktop.
Umami Wordpress - Add Umami Analytics Code in Wordpress Site - Add this below Code in your Site Specific Plugin or Themes Functions File.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function umami_preconnect_url(){ | |
if(! is_user_logged_in()){ | |
echo '<link rel="preconnect" href="https://umami.example.com" />'; | |
} | |
} | |
add_action('wp_head', 'umami_preconnect_url'); | |
function umami_track_code() { | |
if(! is_user_logged_in()){ | |
?> | |
<script async defer data-website-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" src="https://umami.example.com/umami.js"></script> | |
<?php | |
} | |
} | |
add_action('wp_head', 'umami_track_code'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment