Get emails of users from the email field of Hubspot contact from - wordpress

On my WordPress website I have a contact form built in Hubspot. I got the script of this form from Hubspot and past it in my contact page (https://stagezero.ai/contact/).
<script>
hbspt.forms.create({
region: "na1",
portalId: "20085053",
formId: "412d2c51-95f1-4a6c-b3f3-f71c5852ac98"
});
</script>
Whenever the form is submitted the user is redirected to our thank you page (https://stagezero.ai/thank-you/).
So, whenever someone submit the form I want to extract the Emails of our users from the email field on our contact from. So basically, the goal is to get the emails stored as a variable so that it can be hashed and sent to google analytics.
I have tried to do it by myself by writing and pasting this code in my contact page but unfortunately it did not work. Can some help me to achieve the goal which I have mentioned above?
Thank you.
<script>
//code to get email values from contact form’s email field
var form = document.getElementById("hsForm_412d2c51-95f1-4a6c-b3f3-f71c5852ac98");
var email_field=document.getElementById("email-412d2c51-95f1-4a6c-b3f3-f71c5852ac98");
form.onsubmit = function(){
var email = email_field.value();
//code to send email values to Google Analytics
dataLayer.push({
'event':'form_submit',
'enhanced_conversion_data': {
"email": email // replace 'yourEmailVariable' with email variable //
}
});
};
</script>

Related

How can i remove billing address field in stripe checkout form?

I am using a custom code in WordPress for redirecting to checkout page of stripe but stripe checkout form is showing billing address
var data = {
action:'sendpayment',
currency:currency,
amount:amount,
payment_method_types:["card"]
};
jQuery.post(window.location.origin+'/wp-admin/admin-ajax.php', data, function(response) {
response= JSON.parse(response);
if(response.sessionId){
stripe.redirectToCheckout({
sessionId: response.sessionId,
}).then(handleResult);
}else{
handleResult(response);
}
});
You can specify billing_address_collection as required which will only collect it if it's necessary (at Stripe's determination). There is not an option to tell Stripe to never collect it, though.

Displaying Form pop up on Click of add to cart button in Woocommerce

I want a pop up contact form to be displayed (if user is not registered) on click of add to cart button. The pop up form will take all the details of the user. On click of submit button of form , mail should be sent to the user consisting of the information of the respective product plus mail should go to wordpress admin.
You have to do like this.
<script>
jQuery('.add_to_cart_button ').click(function(e) {
e.preventDefault();
var ProductId = jQuery(this).data("product_id")
addToCart(ProductId);
return false;
});
function addToCart(ProductId) {
//show popup for fet user details in popup
// process user data
}
</script>

Make changes to the Edit Account Details page

Currently the Edit Account Details page have these fields: First Name, Last Name, Email address, Current Password & New Password. Now I need to overwrite the 'Save Changes' button which basically submits the form to update the user details. Before the form is being submitted, I want to do a javascript-based validation which checks the user's new password. How can I do this?
Btw I'm using WooCommerce, if that matters here.
You can use woocommerce_edit_account_form_end action to inject your custom JS snippet and do your validation.
like this
function add_my_account_edit_script() { ?>
<script type="text/javascript">
(function($){
$(document).ready(function(){
$("form.edit-account").submit(function(){
var old_pass = $("#password_1").val();
var new_pass = $("#password_2").val();
if( old_pass != new_pass ) {
// Show your validation message here
// return false to prevent the form submitting
return false;
}
// no validation error so allow the form to be submitted.
return false;
});
});
})(jQuery);
</script>
<?php
}
add_action( 'woocommerce_edit_account_form_end', 'add_my_account_edit_script' );

Google AdWords click conversion is "unverified"

I've got an online store build on ASP.NET web forms. When a customer goes to the checkout page, there is a form, where they have to provide their details, like postage address etc. After they filled the form in they have to click "Pay now" button to be prompted to go to Paypal checkout page.
I need to track those clicks for the Google AdWords conversion statistics.
The usual code for tracking clicks would look like:
// some data
goog_report_conversion = function(url) {
goog_snippet_vars();
window.google_conversion_format = "3";
var opt = new Object();
opt.onload_callback = function() {
if (typeof(url) != 'undefined') {
window.location = url;
}
But because of the way the website was implemented, the destination link is being generated dynamically, so I couldn't pass it as as argument for "goog_report_conversion".
So I've slightly changed the conversion function to this:
// some data
goog_report_conversion = function(id) {
goog_snippet_vars();
window.google_conversion_format = "3";
var opt = new Object();
opt.onload_callback = function() {
if (typeof(id) != 'undefined') {
// I use custom function to trigger click on the actual button
event_fire(document.getElementById(id), 'click');
}
}
And I have this HTML structure:
<span class="GeneralFormButton" onClick="goog_report_conversion('submit_all')">Pay Now</span>
<input type="button" name="submit_all" value="Pay Now" onclick="this.disabled=true; this.value='Plase wait';__doPostBack('submit_all','')" id="submit_all" style="display: none;" />
Where <span> is being used to trigger the conversion function and then to emulate "click" on the actual submit button.
It works well and the customer is redirected to Paypal. However, the conversion isn't tracked and in Google AdWords account my "Pay with Paypal" option is marked as "Unverified" (It's been going for a way longer than 24 hors)
I tested what data is sent to google on submit:
https://www.googleadservices.com/pagead/conversion/*correct conversion id*/?random=1459744659796
&cv=8
&fst=1459744659796
&num=1
&fmt=3
&label=*correct conversion label*
&guid=ON
&u_h=800
&u_w=1280
&u_ah=777
&u_aw=1280
&u_cd=24
&u_his=11
&u_tz=570
&u_java=false
&u_nplug=5
&u_nmime=7
&frm=0
&url=http%3A//www.website.com/store_checkout2.aspx%3Fpay_service%3DPayPal%26promo_code%3D%26voucher%3D
&ref=http%3A//www.website.com/store_checkout2.aspx%3Fpay_service%3DPayPal%26promo_code%3D%26voucher%3D
&tiba=Contact%20and%20Delivery%20Address
&async=1
The conversion id and label are correct, the rest of the data seems to be okay too, but the conversion is still not tracked. I just can't figure out why.
Where did I go wrong and what do you think needs to be changed?
Thanks very much in advance
It turned out that the form was never completed and sent before, therefore Google couldn't verify the code. While I was testing for response data I sent the form and the code got verified.

linkedin public profile url memberdata plugin

I am trying to create a company directory which will provide a link to an employees linkedin public profile, if the uses chooses to connect.
So on our employee profile page, the user can choose to link their linkedin account to their employee profile. We initiate an oAuth process and we retrieve their hashed linkedin id, which we then store. Great. Now the part that isn't working.
Based on their plugin example, i have this...
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxxxxxxxxxx
authorize: false
</script>
<script type="text/javascript">
function INTEST() {
IN.API.Profile().ids("pU-LBvD_y0")
.fields(['id', 'firstName', 'lastName', 'picture-url', 'public-profile-url'])
.result(function (result) {
profile = result.values[0];
})
.error(function (errorResult) {
var i = 0;
});;
}
</script>
I receive all information except the public-profile-url.
Any help would be greatly appreciated.
I'm sure you have this figured out by now. But for the benefit of others:
When using the JavaScript API you must convert the profile field names from the dashed notation to studly caps. For example first-name becomes firstName. public-profile-url becomes publicProfileUrl
Reference the following API documentation at
http://developer.linkedinlabs.com/tutorials/jsapi_profile/

Resources