Title: Google Analytics Code
Last modified: June 8, 2021

---

# Google Analytics Code

 *  [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [5 years ago](https://wordpress.org/support/topic/google-analytics-code-17/)
 * Hey,
 * I’ve noticed that Google Analytics is tracking a big drop in page views, but 
   not in sessions. I’m wondering how to make AjaxLoadMore is tracking a new pageview
   each time a story is loaded in my example site.
 * We have the google analytics tracker in our header.php file but I saw in the 
   settings that it says “Must have a reference to your Google Analytics tracking
   code on the page.” Does that mean I need to put the tracker inside of the single.
   php file or do I need to add it into the repeater template?
 * Thanks for your time.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fgoogle-analytics-code-17%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Thread Starter [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [5 years ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14543223)
 * Just bumping this.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14554358)
 * [@markelrayes](https://wordpress.org/support/users/markelrayes/) Sorry, missed
   this one.
 * You can add the following hook to trigger a `console.log` after a page view has
   been sent.
 *     ```
       add_filter('alm_ga_debug', function() {
       	return true;
       });
       ```
   
 * Let me know if this helps.
 *  Thread Starter [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14554406)
 * Should I just paste that into function.php? I’m guessing it show show True inside
   the console log after I do…
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14554424)
 * Yes, functions.php
 * It should say, `Ajax Load More: Page View sent to Google Analytics`
 * Or something similar. I can’t remember 100%
 *  Thread Starter [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14554483)
 * Yeah it’s not logging.
 * Here is the code I used
 *     ```
       if ($marketfilter == 'story-market') {
       			echo do_shortcode('[ajax_load_more single_post="true" single_post_id="' . get_the_ID() . '" single_post_order="query" single_post_query_order="latest" repeater="template_6" post_type="stories" meta_key="story_market' . ($filtertopics ? $filtertopicstax : NULL) . '" meta_value="' . $market . ($filtertopics ? $filtertopics : NULL) . '" meta_compare="=:LIKE" meta_relation="AND" meta_type="CHAR:CHAR" scroll_distance="-500" posts_per_page="1" taxonomy="' . ($filtermarkets ? $filtermarketstax : '') . ($filtermarkets & $filtersectors ? ':' : '') . ($filtersectors ? $filtersectorstax : NULL) . '" taxonomy_terms="' . ($filtermarkets ? $filtermarkets : NULL) . ($filtermarkets & $filtersectors ? ':' : '') . ($filtersectors ? $filtersectors : NULL) . '" taxonomy_operator="IN:IN" cache="true" cache_id="market-stories-' . $market . '" seo="true"]');
       		}'
       ```
   
 * and here is a sample page:
 * [https://www.connectcre.com/stories/savills-acquires-workplace-solutions-advisor-t3/](https://www.connectcre.com/stories/savills-acquires-workplace-solutions-advisor-t3/)
 *  Thread Starter [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14558800)
 * Giving a little bump :]
    -  This reply was modified 4 years, 12 months ago by [markelrayes](https://wordpress.org/support/users/markelrayes/).
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14558877)
 * Are you using GTM or Google Analytics?
    GTM does not integrate. [https://connekthq.com/tracking-virtual-pageviews-google-tag-manager/](https://connekthq.com/tracking-virtual-pageviews-google-tag-manager/)
 *  Thread Starter [markelrayes](https://wordpress.org/support/users/markelrayes/)
 * (@markelrayes)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14559109)
 * We are using Google Site Tag. Do you know if I can use the solution above since
   they are the same framework or do you have a better suggestion?
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14560145)
 * Im not sure, sorry. I’ve never used Google Site Tag before. I’d need to take 
   this away and find some time to investigate.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Google Analytics Code’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * Last activity: [4 years, 12 months ago](https://wordpress.org/support/topic/google-analytics-code-17/#post-14560145)
 * Status: not resolved