Title: Custom code with php
Last modified: March 3, 2017

---

# Custom code with php

 *  Resolved [cassianotartari](https://wordpress.org/support/users/cassianotartari/)
 * (@cassianotartari)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-code-with-php/)
 * Hi!
 * I would like to group pageviews by main category of my posts. Like someone asked
   here [http://stackoverflow.com/questions/36206509/google-analytics-grouping-page-views-by-page-category-wordpress](http://stackoverflow.com/questions/36206509/google-analytics-grouping-page-views-by-page-category-wordpress)
 * Looking inside Monster Insights settings there is a “Custom code” field that 
   I believe I can add some JS call.
 * But How can I call the php wordpress function get_the_category() inside this 
   custom code?
    `ga('set', 'contentGroup1', '<?php get_the_category() ?>');`
 * This will work?
    -  This topic was modified 9 years, 3 months ago by [cassianotartari](https://wordpress.org/support/users/cassianotartari/).

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

 *  Plugin Author [chriscct7](https://wordpress.org/support/users/chriscct7/)
 * (@chriscct7)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-code-with-php/#post-8870928)
 * Hi there.
    No the custom JS section will only run Javascript.
 * -Chris
 *  Thread Starter [cassianotartari](https://wordpress.org/support/users/cassianotartari/)
 * (@cassianotartari)
 * [9 years, 3 months ago](https://wordpress.org/support/topic/custom-code-with-php/#post-8870940)
 * Resolved?
 * Is there any way to extend the plugin code inside functions.php to achieve this
   group pageviews by post category?

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

The topic ‘Custom code with php’ is closed to new replies.

 * ![](https://ps.w.org/google-analytics-for-wordpress/assets/icon.svg?rev=2976619)
 * [MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)](https://wordpress.org/plugins/google-analytics-for-wordpress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/google-analytics-for-wordpress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/google-analytics-for-wordpress/)
 * [Active Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/google-analytics-for-wordpress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/google-analytics-for-wordpress/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [cassianotartari](https://wordpress.org/support/users/cassianotartari/)
 * Last activity: [9 years, 3 months ago](https://wordpress.org/support/topic/custom-code-with-php/#post-8870940)
 * Status: resolved