Title: Issue using gtag code
Last modified: March 27, 2018

---

# Issue using gtag code

 *  [wp_n00bst3r](https://wordpress.org/support/users/wp_n00bst3r/)
 * (@wp_n00bst3r)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/issue-using-gtag-code/)
 * I have followed the steps listed here for using Google Analytics: [https://contactform7.com/tracking-form-submissions-with-google-analytics/](https://contactform7.com/tracking-form-submissions-with-google-analytics/)
 * Here is my code in my functions file:
 *     ```
       <?php
       add_action( 'wp_header', 'mycustom_wp_header' );
   
       function mycustom_wp_header() {
       ?>
       <script type="text/javascript">
       document.addEventListener( 'wpcf7mailsent', function( event ) {
           gtag('event', 'conversion', {'send_to': 'XXXXXXXXXXXX'});
   
       }, false );
       </script>
       <?php
       }
       ?>
       ```
   
 * I cannot get the gtag to work (track form submissions). I was able to get ga 
   to work fine. Any suggestions would be greatly appreciated, thanks!

Viewing 1 replies (of 1 total)

 *  [Loran A. Rendel](https://wordpress.org/support/users/loranrendel/)
 * (@loranrendel)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/issue-using-gtag-code/#post-10133017)
 * Probably it should be `add_action( 'wp_head', 'mycustom_wp_header' );`

Viewing 1 replies (of 1 total)

The topic ‘Issue using gtag code’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

## Tags

 * [form submissions](https://wordpress.org/support/topic-tag/form-submissions/)
 * [tracking](https://wordpress.org/support/topic-tag/tracking/)

 * 1 reply
 * 2 participants
 * Last reply from: [Loran A. Rendel](https://wordpress.org/support/users/loranrendel/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/issue-using-gtag-code/#post-10133017)
 * Status: not resolved