Google Analytics Experiments - get experiment variation - events

I am measuring conversion rates between two sites - one site (abc.com) has an iframe with registration form from another (cde.com). I need to measure REAL conversion rate, which means only successfull registrations. For this I am using server side google analytics library (https://github.com/dancameron/server-side-google-analytics) that sets an event when a registration is successfully completed.
I have to use events, since I have no thankyou.html pages, the other app is fully ajax based.
Using cde.com as a thankyou.html page gives numbers like 98% conversion, which is not quite accurate. Besides that I only need to track registration that came from the abc.com.
I was able to achieve the event tracking but now I don't know, how to set the event in a way that tells GA that it came from a certain variation of abc.com.
This is the code, that sets the event. The parameters are similar to _gaq.push()
$ssga->set_event( "Category", 'Created an account' );
$ssga->send();

Pass information from abc.com to cde.com using the query string:
<iframe src="cde.com?variation=1"></iframe>
Then include that information in the form at cde.com:
if (isset($_GET['variation'])) {
echo '<input type="hidden" name="variation" value="' . $_GET['variation'] . '" />';
}
Then in your event-sending code, include the variation information:
if (isset($_POST['variation'])) {
if ($_POST['variation'] == 2) {
$ssga->set_event( "Category", 'Created an account', 'Variation 2' );
}
else $ssga->set_event( "Category", 'Created an account', 'Variation 1' );
}
else $ssga->set_event( "Category", 'Created an account, 'Variation 1' );
$ssga->send();

Related

In Zoho Creator unable to pass the decision from Zoho Workflow (deluge script) to Zoho Form

I have a calculator whose output i need to display on Submit button. The output comes from a decision tree running in Zoho Workflow module using deluge script.
1) Have tried storing the output in workflow as a string and then passing it back to a form field
2) Tried creating a zoho page for output display but unable to link output of workflow and zoho page
if(input.Price > input.Income)
{
if(input.EMI_Exp < 0.6)
{
info "Take the Personal Loan as you can easily manage the EMI.
If you choose a credit card then you will mess your cashflow";
}
else
{
info "No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this";
}
}
else
Need to pass the info information to a decision box ( text) in Zoho form.
On submit of the form, if you are willing to display a message to the user, you can make use of two things page or stateless form.
Page:
Create a page on creator and names it as Message ( You can name it as
you wish )
Add parameters to the page by name recordID ( datatype of
the variable is string & can have any name ).
On page fetch record information from the form and using recordID( convert into
to long as it is string whereas ID is bigint ). i.e
response = FormName[ID == recordID.toLong()]
if(response.EMI_Exp < 0.6)
{
%><p>
Take the Personal Loan as you can easily manage the EMI. <br>
If you choose a credit card then you will mess your cashflow
<p><%
}
else
{
%>
<p>
No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this
</p>
<%
}
}else{
%>
<p>
Thank you!!!
</p>
<%
}```
On click of submit button use open url :
openUrl("#page:pageLinkName?zc_LoadIn=dialog&recordID="+input.ID,"same window"), using the script you can open a dialog box
Stateless Form:
Create a stateless form ( Name it as Message or anything you want)
Add two field a single-line text field and name it as recordID and
note field and keep it empty without any value and name it as
Message
On load hide recordID field and using recordID fetch record details
i.e
response = FormName[ID == recordID.toLong()];
if(response.Price > response.Income) {
if(response.EMI_Exp < 0.6)
{
input.Message = "Take the Personal Loan as you can easily manage the EMI.
If you choose a credit card then you will mess your cashflow";
}
else
{
input.Message = "No Personal Loan, No Using Credit Card. You are stretching
yourself by purchasing this";
} }
else{ input.Message= "Thank you !!!" }
On Submit of calculator form using following script :
openUrl("#Form:formLinkName?zc_LoadIn=dialog&recordID="+input.ID,
"same window")```
, using the script you can open a dialog box
Hope this could help you.

fine uploader changing the input name to match what my script is expecting

I am incorporating Fine Uploader into a form that already exists.
I've added three Fine Uploader file upload fields. I have one script that controls all three of the boxes. I looked at the inputName attribute and attempted to change that, but it changed the name of all of the fine upload fields to what i set as the inputName (in this case it was photo1). That's not exactly what i want. I want to set the inputName for each field to something different.
In my case, it is important that I have 3 individual boxes because I have a message box that goes with each photo.
I mainly just want to use Fine Uploader for its ability to allow iphone users to select a photo if they are on the phone and also for the thumbnail preview after the photo is selected. All that stuff is great.
The rest of the form I have is already functioning and I can submit it using standard input file fields.
Questions:
Is there a way to use multiple fields on a single page? Do I need to
write a seperate $('#photo1').fineUploader(){...}); per input box?
Is there a way to change the input name for each file upload field?
I assume i can achieve this with seperate script blocks, but is
there a better/cleaner than repeating all that code?
I downloaded the PHP Server Handler files and when i submit my test form with interceptSubmit: true, I see the images upload to my server. That works. (i kinda made a simple form just to test it out). When i change to interceptSubmit: false, add a page called thankyou_post.php as my post action page and in that page I'm just seeing what the form is sending by print_r($_POST); and all i get is Array ( [submit] => submit ) as the response.
I suppose my next step will be to try to write custom blocks per file field and see if the form can process that better.
$(document).ready(function () {
$('#photo1, #photo2, #photo3').fineUploader({
debug: true,
template: "qq-dav-photo-with-thumb",
thumbnails: {
placeholders: {
waitingPath: "placeholders/waiting-generic.png",
notAvailablePath: "placeholders/not_available-generic.png"
}
},
form: {
interceptSubmit: false
},
camera: {
ios: true
},
request: {
endpoint: 'thankyou.php',
paramsInBody: true,
inputName: 'photo1'
},
messages: {
emptyError: 'File is empty',
noFilesError: 'No files attached.',
onLeave: 'We are still uploading your files...Please wait.'
},
validation: {
allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
itemLimit: 3,
stopOnFirstInvalidFile: true
}
}).on('progress', function (id, fileName, uploadedBytes, totalBytes) {
console.log('progress...');
}).on('complete', function(event, id, fileName, responseJSON) {
if (responseJSON.success){
file_name = responseJSON.name;
console.log('hoorah! File name: '+file_name);
};
}).on('allComplete', function(event, id, fileName, responseJSON) {
console.log('hoorah! All complete!');
});
});
Any thoughts on what i can do to make this work?
UPDATE #1
LINK: http://ijwebsites.com/fineuploader/
This is the HTML on my form page.
<form action="thankyou_post.php" method="post"
id="qq-form" name="webform" enctype="multipart/form-data" >
<!-- Fine Uploader DOM Element
====================================================================== -->
<div id="photo1"></div>
<br>
<br>
<div id="photo2"></div>
<br>
<br>
<div id="photo3"></div>
<input type="submit" name="submit" value="submit">
</form>
And my thankyou_post.php page for my test page is very basic, i just want it to tell what values were submitted to the page so i am doing on that page:
<?php
if ($_FILES["photo1"]["error"] > 0) {
echo "Error: " . $_FILES["photo1"]["error"] . "<br>";
} else {
echo "Upload: " . $_FILES["photo1"]["name"] . "<br>";
echo "Type: " . $_FILES["photo1"]["type"] . "<br>";
echo "Size: " . ($_FILES["photo1"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["photo1"]["tmp_name"];
}
?>
When I submit the form, i get a message "Error: 4". What do you think the problem is?
If you'd like to have multiple uploaders on the same page, and have varying options for each uploader (in this case, a differing request.inputName option), you'll need to initialize each instance separately. You can combine initialization into a common function that takes the input name as a parameter, if you'd like.
If you want Fine Uploader to send the entire contents of your form, including the selected files, ensure the form.interceptSubmit option is set to true (this is the default anyway). If you do not want this to happen, and you want to upload selected files in a separate request, then you should not enable form support at all in Fine Uploader. Form support was created for those who want Fine Uploader to completely manage a form.
It's not clear from your question what your form or forms look like, as you have left out your markup. If you are expecting Fine Uploader to control multiple file input elements in a single form, then you will need to make use of the extraButtons option.

Wordpress submit post content from front-end with Ajax

I am generating my own Wordpress template and would like to give users a front-end form (so they don't have to log in to the wordpress dashboard) to submit some post content. I've got everything working, thanks to this tutorial - but I'd like to make one enhancement. Currently when the user presses submit the data is stored in wordpress and they are then redirected to a fixed URL of my choosing. Rather than this I would like to simply clear the form data and display a confirmation message - I guess via AJAX? I know there are built in AJAX capabilities in wordpress, but I've never really used it. Can anyone help me out?
The part of the code that submits the data to Wordpress and provides the URL to be redirected is copied below. I assume I wil need to make a change here?
$post_id = wp_insert_post($post_information);
if($post_id)
{
wp_redirect( '/thanks' );
exit;
}
You could simply redirect to the current page with get_permalink():
if ( $post_id )
{
wp_safe_redirect( add_query_arg( array( 'thanks' => '1' ), get_permalink() ) );
exit;
}
To display a message in the template, check the query arg:
if( isset( $_GET['thanks'] ) && '1' == $_GET['thanks'] )
echo '<p class="success">Thanks!</p>';
if you need more featuredone means, try this,
http://kvcodes.com/2014/02/front-end-post-submission-wordpress/

Avoiding Robots from registering on your site

I'm in the process of setting up a basic site for cell phone reviews and information. I keep getting these fake accounts registering and posting content on my site that is not appropriate.
I have just installed the CAPTCHA and image CAPTCHA module, but this doesn't seem to be stopping them.
What is the best way to avoid these fake accounts?
Thank you.
Another strategy is to add another field in the user registration form. Most bots wouldn't know which fields are required, so they fill in everything. If the user enters a value into the new field then don't create an account. You can hide the field from the UI with CSS so that real people won't be able to see the field and enter anything into it. Read Easy spam prevention using hidden forms for a detailed explanation.
To implement this feature into your Drupal site, you need to create a module to alter the user registration form and create a validation for it.
Add another field to the user registration form:
function mymodule_form_alter(&$form, $form_state, $form_id) {
if($form_id == 'user_register_form') {
$form['field_fname'] = array(
'#title' => 'Answer if you are a bot',
'#type' => 'textfield',
);
$form['#validate'][] = 'mymodule_user_bot_validate';
}
}
Add the validation:
function mymodule_user_bot_validate($form, &$form_state) {
if($form['field_fname']['#value'] != '') {
form_set_error('bot_prevention', t('Could not create your account.'));
drupal_goto('user/register');
}
}
Then hide the field with CSS.

Help needed on running a MYSQL script in the background of a web page and taking different actions dependent on the result

I have a form on a web page, with one field to enter a code, to search for a property.
On clicking 'submit' I want to be able to run a script in the background without leaving the page.
The script will need to run a MYSQL statement which will have one of these results:
The property code does not exist, so display a Javascript Alert saying it does not exist.
The property is for sale, so call an existing javscript function 'saleSubmit(propertyCode)' to overwrite the exsiting web page with a new page sale.php for that property code
The property is for rent, so call an existing javscript function 'rentSubmit(propertyCode)' to overwrite the exsiting web page with a new page rent.php for that property code
The property is for sale and rent, so display 2 checkboxes within a div on the page to choose either the sales details or the rental details.
Can anybody point me in the right direction here?
Hi Nick - I think I screwed the system up a bit as I initially posted a question, then created an account which would not let me comment on the thread.
The status of the query is as simple as: does not exist, sale, rent, sale & rent
Extra advice would be really appreciated as I am problems googling for examples or a tutorial to point me in the right direction.
I first took this approach when I was looking at this problem to check that the form and Select statement were working correctly. So my form code looked like this:
<form name="idsearch" action="" method="post" onsubmit="xmlhttpPostForm('includes/idsearch-response.php', 'idsearch', 'idSearchResult', '<img src=\'images/loading.gif\'>'); return false;">
<input type="text" id="idRefNo" name="idRefNo" value="Enter Property Code" onfocus="this.value='';" />
GO <input type="image" src="img/template/search2.gif" alt="Click to Search for Properties"/>
and the php code called looked like this:
$idRefNo = $_POST['idRefNo'];
$query = "SELECT DISTINCT * FROM property WHERE property.Title = '".$idRefNo."' AND suspend != 'Yes'"; $result = #mysql_query ($query);
if ($result) { // If the query runs ok
if ($result != "") {
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
if ($row["BaseRental"] > 0 AND $row["Saleprice"] > 0) {
echo 'This property is for RENT and for SALE <br/>';
} else if ($row["BaseRental"] > 0) {
echo 'This property is for RENT only <br/>';
} else if ($row["Saleprice"] > 0) {
echo 'This property is for SALE only <br/>';
} else {
echo 'DOH! What is going on here!!! <br/>';
}
}
As I said above I would appreciate it if you could point me in the right direction to achieve what I want to do at the beginning of this thread.
First of all let's differentiate between the page(client) and your mysql database(server). Your page will have to send some request to your server which triggers a script to query the database. The result of that query is returned as a response to your page.
You could send a request by using javascript and the xmlhttprequest or try jquery which offers very simple methods to make requests ($.ajax(...)).
Your server and the script which queries your db should then return some meaningful status back to your client which has to interprete the result: Doing alerts, showing your div or whatever you'd like to do. I suggest returning the response as json which can be directly used in javascript without any parsing hassle. If the status of your query as simple as: does not exist, sale, rent, sale & rent. You could go as far and encode those as plaintext numbers, no json needed.

Resources