Lead comes from Facebook Ads or Google Ads .How to verify? - salesforce

window.onload = function () {
alert("previous url is: "+document.referrer);
}
my output ===> previous url is: https://develorercom.visualforce.com/apex/dVFpage?
fbclid=IwAR0DMWaBqOwsMur2wHsi4nyAtvD1z1689XqyZhCujdABjjZEu
Here i click my link from Facebook getting fbcid(Facebook click ID) How to get my previous URl or Domine Name

Related

Checkout page blank before going to payment method url in react project

Hi I am developing an ecommerce site. here I suffer this problem:
Suppose I have an array of product I want to map over the array and hit an post api for all array of items. When all array of items will be post. then I will call another api for getting response.I want to call second api only if the array of elements posted to api.
here is my code :
I am showing all cart items in checkout page. when user want to pay online payment. I place an order and i am getting getway url. I have to clean the cart right? but when my cart cleared the checkout page appearing blank, afer some millisecond page redirect to the gateway URL. I want that after redirect cart will be cleared because if user see blank page it is not good UX.
```await getData(${REST_BASE_API_URL}/mobileapps/orders/${order_id}, {}, userToken())
.then(res => {
let increment_id = res?.increment_id;
if (paymentMethod === 'sslcommerz') {
// navigate('/order-success');
let url = `anything`;
getData(url, {}, userToken())
.then(res => {
window.location.href = res; //redirect to gateway url
dispatch(saveUpdatedCart([])); //cart clear
clearCartAfterOrder(); //set new cart id in redux
console.log('ssl_res', res)
})
.catch(err => {
console.log(err)
})```

Alternative for window.location.href in react for a single-page-application

I have two different react applications, one for customer and one for admin.
Customer app runs on port 3000 and admin on 3001.
I have a button where I want to change from the admin page to the customer page and vice versa.
For now, I am using window.location.href to reload to another url and this works, like this :
onClick={event => window.location.href='http://localhost:3000/customerloginpage'}
I tried redirect and routes and using history but what happens is that it adds the url to the end of the current url instead of replacing ,example :
const history = useHistory();
const customerButtonClicked = () =>{
let path = 'http://localhost:3000/customerloginpage';
history.push(path);
}
Example result :
'http://localhost:3001/adminloginpage/http://localhost:3000/customerloginpage'
Is there a way to do this without having to reload the page with window.location.href? Please explain this concept to me, thanks!

Programmatically navigate to a dynamic url with gatsby

I am using navigate to move to another URL. I saw many posts using Link to move to another page with dynamic url. But I want to change url without writing jsx
When I navigate to the following url, I get a 404 error
navigate(`/vidx/${u}`, {
state: { vid: r }
})
I changed gatsby-node.js to following, still getting the same error. I have a file named vidx.js in pages folder
exports.onCreatePage = async ({ page, actions }) => {
const { createPage } = actions
if (page.path.match(/^\/vidx/)) {
page.matchPath = "/vidx/*";
createPage(page);
}
}
My url will look like this - www.xyz.com/vidx/123456789. The number 123456789 will depend upon the user logged in
I want to redirect to vidx.js; but the URL should be /vidx/123456789
That will never work since /vidx/123456789 will always throw a 404 error since it's not generated and doesn't exist, it's a separate new page.
One easy thing you can do use: /vidx?queryParameter=123456789. In that case, your page will remain being /vidx and you can get the queryParameter to make your stuff with your own logic.

Implementation of Paypal in single page application

I am currently working on a game, which will consist out of an API-based backend, along with a web frontend (which is a single page app, in AngularJS) and on several mobile devices (using Cordova). I am planning on serving the SPA over the main domain name, along with a CDN. The SPA (and homepage) will all be static HTML/Javascript/CSS files, so the only part which is dynamic is the api. The domain name for the "main server" hosting the static sites will be in the style of example.com, the one for the api will be api.example.com
I am wondering how I can integrate Paypal into this scenario though. The internet doesn't seem to offer much advice on how to integrate it into S.P.A's like this...or my google-fu could be off. Thanks for the replies.
Below is how I am handling the situation,
I have a button to say pay with paypal and onClick I open a new window -> window.open("/paypalCreate", width = "20px", height = "20px");
and I capture this get request "/paypalCreate" in my node.js server and call create method which looks liek below
exports.create = function (req, res) {
//Payment object
var payment = {
//fill details from DB
};
//Passing the payment over to PayPal
paypal.payment.create(payment, function (error, payment) {
if (error) {
console.log(error);
} else {
if (payment.payer.payment_method === 'paypal') {
req.session.paymentId = payment.id;
var redirectUrl;
for (var i = 0; i < payment.links.length; i++) {
var link = payment.links[i];
if (link.method === 'REDIRECT') {
redirectUrl = link.href;
}
}
res.redirect(redirectUrl);
}
}
});
};
This redirects user to paypal and once user confirms or cancels payment, the redirect urls are called. And in the success redirect url I capture the payment details into the databse and render a html in this opened window with the confirmation.
exports.execute = function (req, res) {
var paymentId = req.session.paymentId;
var payerId = req.param('PayerID');
// 1. if this is executed, then that means the payment was successful, now store the paymentId, payerId and token into the database
// 2. At the close of the popup window open a confirmation for the reserved listing
var details = {"payer_id": payerId};
paypal.payment.execute(paymentId, details, function (error, payment) {
if (error) {
console.log(error);
} else {
//res.send("Hell yeah!");
res.render('paypalSuccess', {payerId: payerId, paymentId: paymentId});
}
});
};
Once the user closes the opened window in which paypal was being handled the orginal SPA window will be refreshed and thus getting the payment details from the DB and here you can handle the SPA in whatever way you want.
I know that this is a dirty hack, but like you I couldnt find a better way. Please let me know if this works for you or if you have a found a better way to do tihs.
cheers,
Chidan

window.reload reloads before fetching response

i am using jqueryMobile with backbonejs.
task: login form with email and password fields. Fill the form and redirect to same form with 3 links:
update profile
change pwd
logout
Problem: when logout is clicked i wish to redirect it back to the login form(same page) with message-"successfully logged out."
what i did:
in view.js:
$('#logoutClick').click(function() {
console.log("hi");
this.collection = new Fan();
this.collection.logoutFan();
window.location.reload(true);
});
in myController(of cakephp):
public function mobile_logout() {
$status = true;
$event = array();
$data = array();
$this->Auth->logout();
$this->Session->setFlash('Successfully Logged out', 'flash_failure');
$this->Session->delete('Auth.Fan');
$this->set('status',$status);
$this->set('output',$data);
$this->render('/Layouts/json/mobile',false);
}
now when i click on logout, the page is redirected but the message is not rendered.(i guess the page reloads before fetching the response).
When i inspect element in chrome-I can see logout.json with no available preview(json response from controller isn't there).
How do i solve this?
Don't do reload. Use redirect:
window.location = 'yourloginpage?msg=success';
As jQuery mobile simulates one big web page, you cannot reffer to another pages. Using:
window.location.reload(true);
Opens a new view, where jQM starts working once again (it downloads all header files etc). It works like links with rel="external"
If you want to keep jQM working in such case you have to add all headers to your html files and you should be aware you cannot reffer to previous page because it is deleted from DOM.
I did it some different way. It is not perfect:) Try to redirect to another page using $.mobile.changePage("./newpage.html). In this new page add event pageinit and redirect back to the start page.

Resources