Solved

Gravity Forms  submission tracking.

Posted on 2016-10-11
3
45 Views
Last Modified: 2016-10-20
I am trying to add some javascript tracking code to a gravity forms submission.

I would like the following to be added to the submit button :

      <script type="text/javascript">
   window._pq = window._pq || [];
   _pq.push(['track', 'Appcomplete']);
</script>

I know i have to use the gform_after_submission hook below,  but i'm not sure how i would add a javascript script into a php function?

add_action( 'gform_after_submission_1', 'after_submission', 10, 2);
function after_submission() {

}
0
Comment
Question by:jonathan1978
  • 2
3 Comments
 
LVL 25

Expert Comment

by:James Rodgers
ID: 41839996
i think this is more what you are looking for

https://www.gravityhelp.com/documentation/article/gform_post_render/

but the code you provided is not bound to a submit action, it is executed as the page loads, it doesn't need o be bound to a form submit action, just place it on the page in the footer
0
 

Author Comment

by:jonathan1978
ID: 41841058
From what i'm being told,  this is bound when the submit button is clicked.
http://support.perfectaudience.com/knowledgebase/articles/212490-segmenting-api

    <script type="text/javascript">
   window._pq = window._pq || [];
   _pq.push(['track', 'Appcomplete']);
</script>
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
ID: 41841826
from the documentation , something similar to this is what you need

$(document).ready(function() {
  window._pq = window._pq || [];
  $('submitButtonIdentifier').one('click', function() {
    _pq.push(['track',  'Appcomplete');
  }); });

Open in new window


replace 'submitButtonIdentifier' with the id or class of the submit button
ID
'#submitButtonIdentifier'
Class
'.submitButtonIdentifier'
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now