Solved

Gravity Forms  submission tracking.

Posted on 2016-10-11
3
60 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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!
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

19 Experts available now in Live!

Get 1:1 Help Now