-
AuthorPosts
-
January 4, 2016 at 4:40 pm #559284
Hello,
I have different landing pages for different advertisements. I want to track via Google Analytics visitors from which landing page fill in a contact form. How can I achieve this?
This is one of the landing pages:
Kind regards,
Radoslav MitovJanuary 4, 2016 at 4:48 pm #559293Hi radoslavmitov!
Please see – http://kriesi.at/documentation/enfold/add-onclick-event-to-the-contact-form-submit-button/
Regards,
YigitJanuary 4, 2016 at 5:12 pm #559319Hello,
Ok. Can I do all this without a child theme because I don’t have one?
Kind regards,
Radoslav MitovJanuary 4, 2016 at 5:14 pm #559321Hey!
You can add it to functions.php file of your parent theme as well but it would be overwritten in updates. Please see – http://kriesi.at/documentation/enfold/using-a-child-theme/
Best regards,
YigitJanuary 6, 2016 at 1:22 pm #560482Hello,
Thank you.
Since in the description in the article in the first link it is not very clear in this code:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick=\"_gaq.push(['_trackPageview', '/VP/XXX/XXX']);\""; return $att; }
This thing:
onclick=\”_gaq.push([‘_trackPageview’, ‘/VP/XXX/XXX’]);\”
is what I need to replace with my google analytics tracking code which I pasted in the theme, right?
The second question I want to ask is regarding the elements:
$formID and $form_params
What should I write there?
Kind regards,
Radoslav MitovJanuary 7, 2016 at 3:10 am #560922Hi!
You should leave the “$formID and $form_params” variables as they are if you don’t have multiple contact forms. All you have to do is to adjust the tracking code.
Regards,
IsmaelJanuary 7, 2016 at 3:42 pm #561300Hello,
I have multiple contact forms and I want to track them.
How can I adjust it?
Kind regards,
Radoslav MitovJanuary 7, 2016 at 3:56 pm #561308Hey!
Do you have these form on different pages? If so, you can use following code
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ if(is_page(59)) { $att = "onclick=\"_gaq.push(['_trackPageview', '/VP/XXX/XXX']);\""; } if(is_page(61)) { $att = "onclick=\"_gaq.push(['_trackPageview', '/VP/XXX/XXX']);\""; } return $att; }
and change page ID’s to match your pages.
Cheers!
YigitJanuary 7, 2016 at 4:09 pm #561323Hello,
I have forms in three pages. So if we say that page 1 has the following ID: page#1, page 2 – page#2 and page 3 – page#3, and my google analytics tracking code is googleanalyticstracking# will this code be correct:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ ifpage#1) { $att = googleanalyticstracking#"; } ifpage#2) { $att = googleanalyticstracking#"; } return $att; } ifpage#3) { $att = googleanalyticstracking#"; } return $att; }
Kind regards,
Radoslav Mitov- This reply was modified 8 years, 10 months ago by radoslavmitov.
January 8, 2016 at 1:30 pm #561938Hey!
not, it should be:
if(is_page(2))
while “2” is the page-id. See: https://codex.wordpress.org/Function_Reference/is_page
Cheers!
AndyJanuary 8, 2016 at 7:37 pm #562180Hello,
Can you check this one if it is correct?
Kind regards,
Radoslav MitovJanuary 9, 2016 at 8:59 am #562373Hey!
The $att variable should contain the onclick attribute and you need to replace the web property id place holder (/VP/XXX/XXX) with your own id (UA-41252514-11). I don’t see any difference between the tracking codes in your code above so the following should be sufficient for every contact forms in every pages:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick=\"var _gaq = _gaq || [];_gaq.push(['_trackEvent', 'testcategory', 'testaction', 'testlabel', testvalue, true]);\""; return $att; }
For more info regarding ga trackers, please refer to this link: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration?hl=en#_gat.GA_Tracker_._trackPageview
Cheers!
IsmaelJanuary 11, 2016 at 10:03 pm #563505Hello,
I placed this code into my functions.php file and nothing happens. I checked in google analytics for events in real time and I filled the contact form and no event is registered.
What am I doing wrong?
I am posting credentials for my website if you need them.
Kind regards,
Radoslav MitovJanuary 14, 2016 at 6:27 am #565219Hi!
I’m sorry but I guess we provided the wrong tracker code. Did you create a specific goal in the ga dashboard? Here’s how: https://support.google.com/analytics/answer/1032415
Create a new goal (custom) set the type to event, set the conditions then adjust the value of the event conditions (‘testcategory’, ‘testaction’, ‘testlabel’, testvalue) base on the conditions that you set for the event tracker:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick=\"var _gaq = _gaq || [];_gaq.push(['_trackEvent', 'testcategory', 'testaction', 'testlabel', testvalue, true]);\""; return $att; }
If you can provide the login details to the google analytics dashboard. We’ll test it for you.
Regards,
IsmaelJanuary 14, 2016 at 8:58 am #565249Hello,
Ok. Thank you.
I am posting credentials for my google analytics dashboards.
Kind regards,
Radoslav Mitov- This reply was modified 8 years, 10 months ago by radoslavmitov.
January 15, 2016 at 7:31 am #565967Hey!
I created a goal and modified the onclick attribute but I don’t think it’s working yet because google analytics only counts actions per unique sessions. Please track the progress of the goal here:
Real Time: https://www.google.com/analytics/web/?authuser=0#realtime/rt-event/a41252514w96957022p101107789/
You can test the contact form on different networks. I’ll ask the rest of the support team to check the thread because I might be missing something in the goal options.
Best regards,
IsmaelJanuary 16, 2016 at 6:38 am #566464Hi!
UPDATE: Past date conversion is now 6 so I guess the goal is working. :)
For more info regarding event tracking, please visit the link:
https://support.google.com/analytics/answer/1033068#Anatomy
https://developers.google.com/analytics/devguides/collection/analyticsjs/eventsCheers!
IsmaelJanuary 16, 2016 at 8:26 pm #566576Hello,
Thank you. I see it is working now.
My first question is why there are two event categories:
The second question is regarding my original issue. I wanted to track which event from which landing page came. Is that possible?
Kind regards,
Radoslav MitovJanuary 18, 2016 at 4:52 am #566896Hi!
The second category is my first attempt to create the goal. You can disregard that. If you want to alter the category, try to modify the goal event conditions. Regarding the second question, yes, that is possible. Please provide the url of the pages that you want to track. And create different goals for each pages. We will provide the code afterwards.
Cheers!
IsmaelJanuary 20, 2016 at 1:46 am #568268Hello,
Ok. Thank you. I will provide the url. I just want to ask something else. For example now I can see from which landing page a certain visitor filled in the contact form. But is it possible to track which pages does the visitor saw before filling the contact form?
Kind regards,
Radoslav MitovJanuary 20, 2016 at 4:16 am #568349Hey!
I certainly think it’s possible but I haven’t tried it personally. Maybe this article will help: http://www.hallme.com/blog/understanding-next-and-previous-page-path-dimensions-in-google-analytics/
Regards,
IsmaelMarch 10, 2016 at 11:57 am #596234What the final solution for this? I want to use this code but I see in a later post you mention you’ve modified it.
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick=\"var _gaq = _gaq || [];_gaq.push(['_trackEvent', 'testcategory', 'testaction', 'testlabel', testvalue, true]);\""; return $att; }
March 14, 2016 at 7:50 am #597588Hey!
This is the code:
add_filter('avf_contact_form_submit_button_attr','avf_contact_form_submit_button_attr_ga', 10, 3); function avf_contact_form_submit_button_attr_ga($att, $formID, $form_params){ $att = "onclick=\"var _gaq = _gaq || [];_gaq.push(['_trackEvent', 'testcategory', 'testaction', 'testlabel', testvalue, true]);\""; return $att; }
You have to create goals in the ga dashboard: https://support.google.com/analytics/answer/1032415?hl=en
Best regards,
IsmaelMarch 14, 2016 at 11:56 am #597660Fantastic, thank you Ismael – works perfectly.
March 15, 2016 at 6:03 am #598164Hi!
Great! Let us know if you need anything else. You can create a new thread here: https://kriesi.at/support/forum/enfold/
Regards,
Ismael -
AuthorPosts
- The topic ‘Tracking contact form’ is closed to new replies.