• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Feast Design Co.

WordPress Themes for Food & Lifestyle Bloggers

  • Themes
  • Feast Plugin
  • Blog
  • Support
  • Tutorials
  • Nav Social Menu

    • Email
    • Facebook
    • Instagram
    • Twitter
menu icon
go to homepage
  • Feast Plugin
  • Support
  • Tutorials
  • Account
    • Facebook
    • Instagram
    • Twitter
  • search icon
    Homepage link
    • Feast Plugin
    • Support
    • Tutorials
    • Account
    • Facebook
    • Instagram
    • Twitter
  • ×

    Home » How To Customize Your WordPress Themes

    Add Google Analytics Tracking Code

    Do not use a plugin to add Google Analytics tracking.

    Seeing your traffic stats in WordPress is entirely unnecessary. You should be monitoring your search traffic by logging in once per month in order to answer very specific questions. Watching daily and weekly numbers does nothing but give you anxiety.

    Genesis has made it very easy to add scripts to the header and footer areas of your site. One common reason you'd want to do this is to get Google Analytics working on your WordPress site.

    Jump to:
    • Getting the tracking code (Universal Analytics)
    • Inserting the tracking code
    • GA4 setup + install
    • Pagespeed optimization
    • Filtering FBCLID
    • Enable Site Search Tracking
    • Optimizing with Google Analytics
    • GDPR violation
    • Troubleshooting

    Getting the tracking code (Universal Analytics)

    If you haven't signed up for Google Analytics, go ahead and do that. We won't cover that here, because there's 1000 articles already written about it in Google.

    Once signed up, head to Settings > Property > Tracking Info > Tracking Code

    Then grab the gtag.js tracking code:

    Inserting the tracking code

    Use the Admin > Snippets > Add New (Code Snippets plugin) to create a new snippet, with the following code:

    /*
    * we want to use code snippets because the customizer is unreliable
    * note: Google Analytics is not GDPR compliant
    */
    add_action( 'wp_head', 'custom_google_analytics' );
    function custom_google_analytics() {
    ?>
    
    <!-- delete this line and insert the complete Google Analytics code here -->
    
    <?php
    }
    
    

    You're all set to start tracking your site metrics! Google can take up to 24 hours to start processing data, but there should be an option on the page to check it's been implemented right away.

    Remember to flush your cache if you have this in place.

    GA4 setup + install

    The GA4 tracking code can be installed alongside the Universal Analytics tracking code:

    Pagespeed optimization

    We highly recommend everyone have WP Rocket for pagespeeed purposes.

    Make sure you have WP Rocket > File Optimization > Load Javascript Deferred > enabled

    You'll want to add the following to your WP Rocket > Preload > Prefetch DNS Requests

    //google-analytics.com
    //www.google-analytics.com
    //ssl.google-analytics.com

    Filtering FBCLID

    A number of services add tracking parameters to outbound links, including Google Adwords, Facebook, and newsletter. Even the "Customize" screen generates unique URLs that clutter up your Google Analytics.

    Go to Google Analytics > Admin > View > View Settings > Exclude URL Query Parameters

    Here's a starting list that you'll want to expand on: gclid,epik,fbclid,customize_changeset_uuid

    Enable Site Search Tracking

    You'll want to enable site search tracking to see what your visitors are looking for once they land on your site:

    Optimizing with Google Analytics

    This post on optimizing your site with Google Analytics from Tom Crowe Digital has some good tips.

    GDPR violation

    According to a recent ruling from the French data protection authority (CNIL), Google Analytics violates GDPR regulations and should not be served to European citizens.

    At this time we're unaware of any solution which automatically excludes European users.

    Troubleshooting

    If you need further troubleshooting, we recommend hiring Alison at Digital-ade.

    Primary Sidebar

    How To Customize Your WordPress Themes

    • How to Create Multiple Recipe Index Pages
    • How to Set a Favicon
    • Plugins to Install
    • How to Change the Header Size
    • How to Change the Background Color of the Genesis eNews Widgets
    • Font Size for Food Blogs
    • Why is troubleshooting so complex?
    • How to Launch Your Food Blog
    • Add a Before Entry Widget Area
    • Recipe Index: Content Configuration (Cravings Pro + Seasoned Pro)
    • How Do I Set Up My Navigation Menu?
    • Can I Use Multiple Recipe Index Pages?
    • How Do I Update the Theme Version? (without the Feast Plugin)
    • Remove Search Box from Navigation Menu
    • How to Add the Visual Category Page Index
    • Customization Library
    • Setup a secondary navigation menu
    • How to clear your cache
    • Troubleshoot Plugin Conflicts
    • How to Add the Featured Posts Category Index
    • Food Blog Home Page Pagination
    • Cravings Pro Theme: Setup Your Navigation Menu
    • Why we're not supporting Gutenberg Oversized Images
    • Install Theme, and Import Demo Content and Widgets
    • How to change change your footer
    • Seasoned Pro Classic Tutorials
    • Manually Disable Google Fonts
    • Image Alt Tags
    • Why we don't support the read more tag
    • Pinterest for Food Bloggers
    • How to Create Multiple Recipe Index Pages
    • WordPress Settings
    • Foodie Pro Classic Tutorials
    • Brunch Pro Classic Tutorials
    • Cook'd Pro Classic Tutorials
    • Cravings Pro Classic Tutorials
    • All About Featured Images
    • FAQ for All Themes
    • Add Google Analytics Tracking Code
    • Customization Referrals
    • Genesis Child Themes
    • Enable SSL for HTTPS on your Food Blog
    • How to Start a Food Blog
    • Set Up Your WooCommerce Shop
    • The parent theme could not be found. You will need to install the parent theme, genesis, before you can use this child theme
    • Food Blog Theme Features Comparison
    • Translation + Multi Language Support
    • Use Inspect Element to troubleshoot styles

    Free 5-Day Branding Design Challenge

    With this actionable 5-part challenge, you'll have just the digital design strategies you need for a profitable website... and best of all, it's free. Signup and get your first challenge delivered immediately!

    Footer

    ↑ back to top

    Topics

    • Food Blog Design and Appearance
    • Productivity
    • Tech and Plugins
    • Food Blogging and Promotion
    • Minimalist WordPress Themes
    • Simple WordPress Themes
    • Travel blogs
    • Knitting + DIY blogs

    Help

    • Documentation & Tutorials
    • Food Blogging Resources
    • Open A Support Ticket
    • Login
    • Your Account
    • Subscriptions
    • Downloads
    • Discounts and Coupons
    • Compatibility

    Company

    • Subscribe to newsletter
    • Privacy Policy
    • Refund policy
    • Terms & Conditions
    • Principles and Best Practices
    • Affiliates
    • Contact

    Copyright © 2023 · Feast Design Co.

    Results not typical or guaranteed. Our themes and plugins are just a small part of the overall effort involved in running a food blog. Nothing on this website shall constitute legal or financial advice, always consult a local lawyer and accountant. Accessing this website and all transactions herein are under the laws and jurisdiction of Toronto, Ontario, Canada.