Embedding Google Conversion Code in Alert - php

I'm using Avada's template (http://theme-fusion.com/avada/contact/) and working with their contact page. Whenever someone submit's a successful form, the page is being reloaded with an additional "alert" box that's populated with a success message. I'm looking to embed a Google Conversion Pixel in this alert box if possible instead of having to send the user to a whole new page. The code that creates the alert box is
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
<?php echo do_shortcode( '[alert type="success" accent_color="" background_color="" border_size="1px" icon="" box_shadow="yes" animation_type="0" animation_direction="down" animation_speed="0.1" class="" id=""]' . __( 'Thank you', 'Avada' ) . ' <strong>' . $name . '</strong> ' . __( 'for contacting us! Your email was successfully sent!', 'Avada' ) . '[/alert]' ); ?>
<br />
<?php } ?>
which generates
<div class="fusion-alert alert success alert-dismissable alert-success alert-shadow">
<button type="button" class="close toggle-alert" data-dismiss="alert" aria-hidden="true">×</button>
<span class="alert-icon">
<i class="fa fa-lg fa-check-circle"></i>
</span>
Thank you <strong>Test</strong> for contacting us! Your email was successfully sent!</div>
<br />
</div>
Code looking to embed looks like this
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "1";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1/?label=1&guid=ON&script=0"/>
</div>
</noscript>
Any help is greatly appreciated

Since each line has opening and closing php tags you can simply paste the html code between two php blocks (but after the "if" block). You might choose to just use the image tag from the noscript block (conversions will still be tracked).
<?php if(isset($emailSent) && $emailSent == true) { //If email is sent ?>
// just the noscript image tag, alternatively paste the whole code here
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1/?label=1&guid=ON&script=0"/>
<?php
echo do_shortcode( '[alert type="success" accent_color="" background_color="" border_size="1px" icon="" box_shadow="yes" animation_type="0" animation_direction="down" animation_speed="0.1" class="" id=""]' . __( 'Thank you', 'Avada' ) . ' <strong>' . $name . '</strong> ' . __( 'for contacting us! Your email was successfully sent!', 'Avada' ) . '[/alert]' ); ?>
<br />
<?php } ?>

Related

Bootstrap popover doesn't show

I want to show popover but I don't see it.
CODE
echo '
<a data-toggle="popover"
data-trigger="hover"
data-html="true"
data-placement="top"
data-content="HTML MARKUP"
class="cf_box popover-extra-balik ' . $this->custom_fields[ 34 ]->name . ' ' . $i->fields[ 34 ] . ' ">
';
echo '<span class="field_value">' . JText::_( 'COM_DJCLASSIFIEDS_EXTRA_BALIK_PREMIUM' ) . '</span>';
echo '</a>';
Website Link: link
Image: Image
Thanks!!
Add below Javascript in your code.
$(function () {
$('[data-toggle="popover"]').popover()
});
Example
I removed some PHP code because it's not supported here.
$(function() {
$('[data-toggle="popover"]').popover()
});
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<a data-toggle="popover" data-trigger="hover" data-html="true" data-placement="top" data-content="<strong>BALÍK PREMIUM obsahuje :</strong>
<ul>
<li>sezónne pneumatiky</li>
<li>najbližšiu servisnú prehliadku so zľavou</li>
<li>dezinfekcia vozidla</li>
<li>1 x čistenie a doplnenie klimatizácie počas leta zdarma</li>
<li>povinná výbava zdarma</li>
<li>zvýhodnené financovanie</li>
</ul>" class="cf_box popover-extra-balik">
<span class="field_value">BALIK_PREMIUM</span>
</a>
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>

Sending and checking if mail is being sent from localhost xampp

Here is my code for "forget password" module in my website. I want to check on xampp server,before deploying to live server, whether mails are sent and received. Currently its not working at all. I have made required changes into php.ini and sendmail.ini. Can somebody plz let me know where am i going wrong..
<?php
#session_start();
require("includes/config.php");
require("classes/Database.class.php");
require("classes/security_functions.php");
include('classes/ps_pagination.php');
require_once('classes/validation.class.php');
require("classes/site_functions.php");
$obj = new validation();
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$sec = new security_functions($db);
$fnc=new site_functions($db);
$errmsg = '' ;
$succmsg = '' ;
if(isset($_POST['btnRecovery']))
{
$email = mysqli_real_escape_string($db->link_id,(trim($_POST['email'])));
if(empty($email))
{
$errmsg .= 'Please Enter Email<br>';
}
if(!empty($email)){
if (!preg_match('/^[-._a-zA-Z0-9]+#[a-zA-Z0-9-._]+\\.[a-zA-Z]{2,4}$/', $email) || strlen($email) < 8 || strlen($email) > 100)
$errmsg .= 'Please Enter Valid Email ID<br>';
}
$check1= $fnc->fieldTocheckPassword("tbl_user","email",$email, 3);
if(!empty($check1))
{
$errmsg .= 'Please Enter your registered Email ID<br>';
}
if(empty($check1))
{
$password1 = time()+rand(0, 9) ;
$password = md5($password1) ;
$res = mysqli_query($db->link_id,"UPDATE tbl_user SET password = '$password', raw_password='$password1' WHERE email = '$email' AND type = 3");
$msg = '<table width="600" style="border:solid; color:#006200;">
<tr><td colspan="3" align="left">Dear User, <br>
Your Login Details are as given below:</td></tr>
<tr><td>Login Id:</td><td>:</td><td>'.$email.' </td></tr>
<tr><td>Password:</td><td>:</td><td>'.$password1.' </td></tr>
<tr><td style="height:40px;" colspan="3"></td></tr>
<tr><td colspan="3">Team</td></tr>
<tr><td colspan="3">AAFM</td></tr>
<tr><td style="height:40px;" colspan="3"></td></tr>
<tr><td colspan="3">Note: We recommend you to please reset your password while login.</td></tr>
</table>';
$subject = "Password Recovery from AAFM";
$headers ='MIME-Version: 1.0' . "\r\n".
'Content-type: text/html; charset=iso-8859-1' . "\r\n".
'From: no-reply#aafm.com"\r\n"' .
'Reply-To: ravinsoam#gmail.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
ini_set('smtp_port',587);
mail($email, $subject, $msg, $headers) ;
$succmsg = "Please Check you Email.<br>Password has been send on your email id.<br>Please check your inbox/ spam folder." ;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- Meta -->
<title>AAFM</title>
<!-- CSS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,300,400,600,700,800' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="engine1/style.css" />
<link rel="stylesheet" type="text/css" href="css/hover.css" />
<script type="text/javascript" src="engine1/jquery.js"></script>
</head>
<body>
<!-- Start WOWSlider.com BODY section -->
<div id="wowslider-cover"> </div>
<div id="wowslider-container1">
<div class="ws_images">
<ul>
<li><img src="data1/images/01.jpg" alt="167160841" title="167160841" id="wows1_1"/></li>
<li><img src="data1/images/02.jpg" alt="101698382" title="101698382" id="wows1_2"/></li>
<li><img src="data1/images/03.jpg" alt="146820126" title="146820126" id="wows1_3"/></li>
</ul>
</div>
<span class="wsl">DHTML Slideshow by WOWSlider.com v5.2</span>
<div class="ws_shadow"></div>
</div>
<script type="text/javascript" src="engine1/wowslider.js"></script>
<script type="text/javascript" src="engine1/script.js"></script>
<!-- End WOWSlider.com BODY section -->
<form action="" method="post">
<div class="loginPanel">
<div class="loginPanelContent FormDiv">
<div class="div_1_of_1"><img src="images/logo-1.png"></div>
<!--<div class="div_1_of_1 LH1">My Payroll Online</div>-->
<div class="div_1_of_1"><div class="error">
<?php
if($errmsg !="")
{
echo ucwords($errmsg );
}
?>
<?php
if($succmsg !="")
{
echo ucwords($succmsg );
}
?> </div>
<input type="text" placeholder="Email" name="email" required="email" id="username">
</div>
<div class="div_1_of_1" style=" margin-bottom:0;">
<ul class="loginUl">
<li><input name="btnRecovery" type="submit" class="button curl-top-right2" style="width:100%" value="Submit" /></li>
<li>Existing User ?</li>
</ul>
<div class="div_1_of_1" style="display:none;">
Forgot Password ?
</div>
</div>
</div>
</div>
</form>
<!-- Footer -->
<div id="footer" class="clearfix">© 2016 - AAFM India - All Rights Reserved.</div>
<!-- /Footer -->
</div>
<script language="javascript" type="text/javascript">
$(document).ready( function() {
$('#ForgotPassword').click( function() {
if( !$("#username").val() ) { alert("Please enter your username!") }
else { alert("Password has been sent to your email address!") }
});
});
</script>
</body>
</html>
What is your XAMP configuration ?
by default, the file xampp\sendmail\sendmail.ini, contains the line
smtp_server=mail.mydomain.com
You need to change to
smtp_server=localhost

How to make an id from a PHP while echo loop make work with JQuery AJAX

I want to make an id reference "logout" work when clicked from my php code. Please this would aid me very well in continuing the project. this method is important because it involves phonegap
php file
The php file gets user details from the database. the logout id is used to call the php page through an AJAX request and then log the user out and redirect them.
<?php
session_start();
$con = mysqli_connect("localhost", "*****", "*****", "*****");
//check connection...
if ($con === false) {
die ("couldn't connect to SQL Server");
}
if (isset($_SESSION['people_email'])){
$selectdata = "SELECT * FROM people WHERE people_email = '".$_SESSION['people_email']."'" ;
$query = mysqli_query($con, $selectdata);
while ($row = mysqli_fetch_array($query)) {
echo '<div class="ui fluid card">';
echo '<div class="extra content">';
echo '<div class="left floated meta">';
echo '<a href="#" id="logout">';
echo '<i class="remove circle icon"></i>';
echo "Log out";
echo '</a>';
echo '</div>';
echo '<div class="right floated meta">';
echo '<a>';
echo '<i class="plus icon"></i>';
echo "Upload a photo";
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="image">';
echo '<img src="/images/avatar2/large/kristy.png">';
echo '</div>';
echo '<div class="content">';
echo '<a class="header">'.$row['people_name'].'</a>';
echo '<div class="meta">';
echo '<span class="date">'.$row['people_name'].'</span>';
echo '</div>';
echo '<div class="description">'.$row['people_email'].'</div>';
echo '</div>';
echo '<div class="extra content">';
echo '<a><i class="send icon"></i>'.$row['people_username'].'</a>';
echo '<a><i class="alarm icon"></i>'.$row['people_username'].'</a>';
echo '</div>';
echo '</div>' ;
}
}
else {
echo "no";
}
?>
this is the HTML file.
the html file graps the user data for php echo and displays them.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />
<!-- Path to your custom app styles-->
<link rel="stylesheet" href="css/my-app.css">
<link rel="stylesheet" href="Semantic/semantic.min.css">
<!--<link rel="stylesheet" type="text/css" href="css/index.css" />-->
<title>MyApp</title>
</head>
<body>
<!-- Views -->
<div class="views">
<!-- Your main view, should have "view-main" class -->
<div class="view view-main">
<!-- Pages container, because we use fixed navbar and toolbar, it has additional appropriate classes-->
<div class="pages navbar-fixed toolbar-fixed">
<!-- Page, "data-page" contains page name -->
<div class="page " data-page="profile">
<!-- Top Navbar. In Material theme it should be inside of the page-->
<div class="navbar bar-color">
<div class="navbar-inner">
<div class="left"><i class="bell icon"></i>
</div>
<div class="center"><form><input size="50px" type="search" placeholder="Search"/></form></div>
<div class="right">
<!-- Right link contains only icon - additional "icon-only" class-->
<i class="building outline icon"></i>
</div>
</div>
</div>
<!-- Toolbar. In Material theme it should be inside of the page-->
<div class="toolbar toolbar-bottom bar-color">
<div class="toolbar-inner">
<!-- Toolbar links -->
<i class="eye icon"></i>
<i class="calendar icon"></i>
<i class="plus icon"></i>
<i class="user icon"></i>
</div>
</div>
<!-- Scrollable page content -->
<div class="page-content" >
<div id="profile" style="height:90%; width:90%;margin:auto;position:relative;top:20px;"></div>
</div>
</div>
</div>
</div>
</div>
<script src="js/jquery-2.2.3.min.js"></script>
<script src="Semantic/semantic.min.js"></script>
<script>
$(document).ready(function(){
$.ajax({
type: 'get',
url: 'profile.php',
dataType: 'html',
success: function (response) {
$('#profile').html(response);
}
});
$("#logout").click(function() {
$.ajax({
type: 'get',
url: 'logout.php',
success: function (response) {
if (response == "success") {
window.location.href="login.html";
}else{
alert("You were not logged out");
}
}
});
});
});
</script>
</body>
</html>
You can include data attributes like data-page-id in the log out button html and use jQuery's attr() function to fetch that data.
<div id='logout' data-info='some_info'></div>
$('#logout').attr('data-info'); //returns the value
But I don't see why you need this extra info since it's just a log out button and you can bind it's id to click event.

Change input value when i press <a> Attribute

Ok guys already search for it but no results at all, and cant figured it out how to do this, so my problem is:
I have this form:
<form method="POST" action="search.php" name="form" id="form">
<input type="text" name="search" id="search" placeholder="Introduza a sua Localização">
<input type="submit" name="Submit" value="Pesquisar">
</form>
And what i would like to is when i press this:
<a onClick="">City</a>
The input value change to what i want in this case "City" and then automatically submit the form.
I already made a research about this and theres nothing i could take, any help would be appreciated.
Cumps.
Guys thanks to your help now its working but someone tell me please what the problem in this code:
<?php if (mysql_num_rows($tournaments) !=0){
do { ?>
<div id="mainContainer">
<div id="leftContainer"><img src="images/tournaments/<?php echo $row_tournaments['logo']; ?>.png"></div>
<div id="rightContainer">
<div id="rightContent">
<p><?php echo $row_tournaments['description']; ?></p>
<div id="galleryButton"><p>Entrar no torneio</p></div>
</div>
<div id="rightDetails">
<i class="fa fa-gamepad"></i> <?php echo $row_tournaments['game']; ?><br>
<i class="fa fa-calendar-o"></i> <?php echo $row_tournaments['date']; ?><br>
<i class="fa fa-pencil-square-o"></i> Sem comentários<br>
<script type="text/javascript">
function giveThatInputAValue(){
var elem = document.getElementById("search");
elem.value = "<?php echo $row_tournaments['city']; ?>";
/*document.forms["form"].submit();
*/}
</script>
<i class="fa fa-map-marker"></i> <a onClick="giveThatInputAValue()"><?php echo $row_tournaments['city']; ?></a><br>
<img src="images/<?php echo $row_tournaments['online']; ?>.png"> <?php echo $row_tournaments['online']; ?>
</div>
</div>
</div>
<?php } while ($row_tournaments = mysql_fetch_assoc($tournaments));
} else {
?>
<div id="noresults"><p>Sem torneios</p></div>
<?php
}
?>
Everything is looped fine but that part:
<script type="text/javascript">
function giveThatInputAValue(){
var elem = document.getElementById("search");
elem.value = "<?php echo $row_tournaments['city']; ?>";
/*document.forms["form"].submit();
*/}
</script>
Its not looping it only shows the first record why is it?
Any help would be appreciated.
in your js file you can check if the value of the textbox is equal to the cityname you want. if it is then submit the form. Attach the function to your a tag
function SubmitRightCity(){
if(document.getElementById('search').value == "citynamehere"){
document.forms["form"].submit();
}
}
in html
<a onClick="submitRightCity()">City</a>
In the case where you want your a tag to give the input a value, you attach a function to your tag, once the link is clicked, then the function will give your input a value.
<a onClick="giveThatInputAValue()"> City</a>
in javascript file you will have
<script>
function giveThatInputAValue(){
var elem = document.getElementById("search");
elem.value = "My city value";
//if you want to submit the form right after, you add the line below
document.forms["form"].submit();
}
</script>

Google conversions not registering within PHP page

Although relatively new to coding, I have successfully implemented a number of tracking codes before, but I am having serious problems getting one conversion code to register on my site.
Whilst I have put it into the relevant section of PHP in the code, and even done test conversions and seen it in the source, Google has failed to register a single conversion and the goal still shows up as 'Unverified'.
I have read various blogs and what Google has to say about implementing the code in PHP - most of which seem to disagree with one another. If anyone has any ideas, I would be hugely grateful as it is a key indicator to tracking my AdWords performance.
Below is the code that Google gives me to implement untouched:
<!-- Google Code for Almost there Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
var google_conversion_value = 0;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/974608389/?value=0&label=d5KfCMunhgUQhbDd0AM&guid=ON&script=0"/>
</div>
</noscript>
Now the code the way Google wants you to edit it for PHP, detailed under the section here: https://support.google.com/adwords/answer/1722054?hl=en-GB
<!-- Google Code for Almost there Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
if (<%= totalValue %) {
var google_conversion_value = <%= totalValue %>;
}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/974608389/?value=0&label=d5KfCMunhgUQhbDd0AM&guid=ON&script=0"/>
</div>
</noscript>
I have wasted about 3 days on this on and off now and have spent long enough trying to click on adverts and creating fake accounts to test it with to get it to trigger.
As another safeguard I will post the relevant PHP section in it's entirety below too.
It's a part triggered to confirm a subscription payment may be useful to see you can never have too much information, diagnosing a problem.
<?php
/* Template Name: Subscription Confirmation */
if (isset($_POST['activate_subscription']) && isset($_POST['token'])) {
$activation = completeSubscription($_POST['token']);
//completeSubscription Handles everything here. If this even runs, it's all gone wrong.
$activate_failed = true;
} else if (isset($_GET['token']) && isset($_GET['PayerID'])) {
$transaction = getTransactionDetails($_GET['token']);
if ($transaction['ACK'] == "Success") $sub = updateSubscriptionDetails($transaction);
} else {
header("Location: /join/membership/");
exit();
}
get_header();
?>
<div class="row subhero">
<div class="twelve columns">
<?php if (!isset($activate_failed) && $transaction['ACK'] == "Success") { ?>
<h1>Almost there!</h1>
<p class="subheader">Thank you for configuring your subscription with PayPal.</p>
//***************** ANALYTICS CODE
<!-- Google Code for Subscription Conf Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 974608389;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "d5KfCMunhgUQhbDd0AM";
if (<%= totalValue %) {
var google_conversion_value = <%= totalValue %>;
}
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/974608389/?value=0&label=d5KfCMunhgUQhbDd0AM&guid=ON&script=0"/>
</div>
</noscript>
//*********************END OF ANALYTICS CODE
</div>
</div>
</div> <!-- end container -->
<div class="buyticketarea">
<div class="row">
<div class="eight columns offset-by-two">
<p class="subheader">Please confirm the following details. Once you proceed you will be billed immediately for your first month of <strong><?php echo $transaction['L_NAME0']; ?></strong> at <strong>£<?php echo $transaction['L_AMT0']; ?>.</strong></p>
<p class="subheader">Additionally, you will be billed <strong>£<?php echo $transaction['L_AMT0']; ?></strong> on the <strong><?php echo date('j'); ?><sup><?php echo date('S'); ?></sup></strong> of each month, starting on <strong><?php echo getNextBillingDayHuman(); ?>.</strong></p>
<p class="subheader">If you're happy to proceed...</p>
<form method="post">
<input type="hidden" name="sub_id" value="<?php echo $transaction['INVNUM']; ?>" />
<input type="hidden" name="token" value="<?php echo $_GET['token']; ?>" />
<input type="hidden" name="PayerID" value="<?php echo $_GET['PayerID']; ?>" />
<input class="button" type="submit" name="activate_subscription" value="Activate Subscription" />
</form>
</div>
</div>
</div>
This line looks wrong to me:
if (<%= totalValue %) {
var google_conversion_value = <%= totalValue %>;
}
Looking at other examples it should be:
if (<?php echo $totalValue ?>) {
var google_conversion_value = <?php echo totalValue ?>;
}
But, you aren't setting the value for $totalValue so maybe all conversions have equal value? In which case you should just use:
var google_conversion_value = 10;

Categories