Omniture form complete tracker currently fires twice - adobe-analytics

I am currently using Omniture analytics for form tracking.
when i paste the following text on the button click event on the registration.cshtml page it fires only once which is right.
var s = s_gi(s_account);
s.linkTrackVars = 'prop1,prop8,eVar1,eVar8,events';
s.prop1 = 'Registration'; s.prop8 = 'Tier 3|Form Complete';
s.eVar1 = s.prop1;
s.eVar8 = s.prop8;
s.linkTrackEvents = 'event2,event8'; s.events = 'event2,event8';
(s.tl(this, 'o', 'Form Complete'));
but this is not the right way since the user can make some mistakes while filling up the form so technically the form is not complete.
I have added this in a javascript function which checks if the form is valid only then it should fire the omniture call. but in doing so it is getting fired twice.

If it's sending two image requests, then that means the function is being called twice, or you have two s.tl functions somewhere.
I would actually recommend sending the data to SiteCatalyst on the registration confirmation page; that way you know for a fact that the data made it to your servers. If there's form info you'd like to send as well, throw it in a query string and use the getQueryParam plugin to take the query string value and pass it as part of the image request.

Related

Twitter replying to tweet twice incorrectly

I wrote a python script which listens for twitter mentions and reply with a text. Everything works well until i decide to change the response text, now i notice everytime a new tweet comes in, the script reply twice, one with the old response text and second with the new text.
Have you come across this before and how were you able to resolve it?
received = "Hey"
response = client.create_tweet(
text=received,
in_reply_to_tweet_id = tweet.id
)

Allowing only one answer in Google forms

Hi I want to create a Google form which i can collect student data,
And i want to make a way to allow my students to only enter one answer one time
in example I want to use this method in the question which asks for the admission number, admission number is a uniqe number which will not be repeated. So if a student enter an admission number that is already entered , I want them to see an error message with "The admission number has been already used"
Issue:
Avoid multiple form responses to be submitted with the same value for a specific form item.
Workflow:
In order to avoid certain responses to be submitted, you have to use some kind of data validation for the Admission number item, as shown in Set rules for your form.
This data validation should be updated every time a form response is submitted, since the newly submitted Admission number should be forbidden in future responses.
In order to update this validation every time the form is submitted, you could use an Apps Script onFormSubmit() trigger, which would then fire a function on every form submission. Let's call this function updateDataValidation.
The onFormSubmit trigger can be installed either manually, following these steps, or programmatically, via executing the function createTrigger from the code sample below once.
Every time updateDataValidation fires, it should do the following:
Find all the previous responses for your Admission number item. You could first retrieve all form responses via Form.getResponses() and then find the responses related to your item by checking its title (see Item.getTitle()).
Transform the array of admission numbers retrieved in previous step into a regex pattern that can be used for the data validation, which could be like this: ^{number1}$|^{number2}$|^{number3}$....
Use TextValidation in order to update the validation rules for your item.
Code sample:
function updateDataValidation(e) {
const itemTitle = "Admission number"; // Name of the form item. Change accordingly
const errorMessage = "The admission number has been already used.";
const form = e ? e.source : FormApp.getActiveForm();
const responses = form.getResponses();
const admissionNumbers = responses.map(response => {
return response.getItemResponses().find(itemResponse => {
return itemTitle === itemResponse.getItem().getTitle();
});
}).map(itemResponse => itemResponse.getResponse());
const numbersPattern = admissionNumbers.map(number => `^${number}\$`).join("|");
const item = form.getItems().find(item => item.getTitle() === itemTitle);
let validation = FormApp.createTextValidation()
.setHelpText(errorMessage)
.requireTextDoesNotMatchPattern(numbersPattern)
.build();
item.asTextItem().setValidation(validation);
}
function createTrigger() {
const form = FormApp.getActiveForm();
ScriptApp.newTrigger('updateDataValidation')
.forForm(form)
.onFormSubmit()
.create();
}
Notes:
In the code sample above, the item Admission number is assumed to be named Admission number. Change that from the code if that's not the case.
In the code sample above, the item Admission number is assumed to be a text item, like Short answer.

Google Forms - confirmation Email summary

I created a form to collect some data. By default the responder to the form gets a PDF summary after submitting the Email. Does anybody know if it is possible to send this summary to a second Email adress I mean a copy of the summary to the form Hoster?
Thanks a lot in advance.
Cheers
Basically repeating what I said in the comments there is no way to add another email address by the UI but you could try to use Apps Script.
You can use a onFormSubmit(), this is a installable trigger that executes every time a form is submitted.
You could try to look at this SO answer, where there is a definition of a trigger and sending a email:
/**
* This function is the one that will be executed every time the trigger is activated
*/
function respondToFormSubmit() {
MailApp.sendEmail ("email#domain.com", "Form Submited: Foo feedback " + Date.now(), "Form Submited: Foo feedback");
}
The setup of the trigger:
var form = FormApp.getActiveForm();
var trigger = ScriptApp.newTrigger('respondToFormSubmit')
.forForm(form)
.onFormSubmit()
.create();

How to fetch mail by id with barbushin imap class

I'm currently working on the imap class by barbushin. It's the only php class over the internet I can find regardless to any encoding issue. Thanks to the coder.
I have a list of messages in a table. Each message sending a message id as GET (say $mid). When a link clicked, the page turned into a view page. It should open that message and display the relevant content right? But it is not. Every message has the same content (the 1st content). The code is designed for gmail but I use it for my client. And it's work.
This is a code:
require_once('../ImapMailbox.php');
define('EMAIL', 'my#domain.com');
define('PASSWORD', '*********');
define('ATTACHMENTS_DIR', dirname(__FILE__) . '/attachments');
$mailbox = new ImapMailbox('{imap.gmail.com:993/imap/ssl}INBOX', EMAIL, PASSWORD, ATTACHMENTS_DIR, 'utf-8');
$mails = array();
// Get some mail
$mailsIds = $mailbox->searchMailBox('ALL');
if(!$mailsIds) {
die('Mailbox is empty');
}
$mailId = reset($mailsIds);
$mail = $mailbox->getMail($mailId);
var_dump($mail);
var_dump($mail->getAttachments());
The original is here: https://github.com/barbushin/php-imap
Finally, I found my way home. According to the script there's a line says "mailId". Which is straight forward what is it about.
It was set to the first array by reset(). So the only thing I need to do is extract the message id from it ($mailId is an array of ids). So I simply add an array behind it.
$mailId=$mailsIds[$_GET[uid]];
While $_GET[uid] is a message id sent from a previous page.

Using changePage to Open a Dialog - Data object not sent

$.mobile.changePage("verify.aspx", { transition: "pop", role: "dialog", data: $("#form1").serialize() });
I'm using the above syntax to open a dialog box and in trying to send the form data via the data argument, nothing is passed.
This is what's being passed in the query string when I open the dialog:
#&ui-state=dialog&ui-state=dialog
(as a side note, this call is originating from a button within another dialog, thus the two ui-state=dialog's)
As you can see, no form data. Any ideas what I can do to persist the data in the url?
Answering my own question:
Found that the data-url attribute of the dialog you request is injected w/ the relative url.
By doing something like:
$("#dialog").on("pagebeforecreate", function (evt) {
var urlObj = $.mobile.path.parseUrl($(this).attr("data-url"));
Will give you access to the url and thus the proper query string values.

Resources