Hi there,
I’m a novice at this, getting started.
I have a repeater which lists products that are loaded into a dataset by verified site members.
That repeater links to a dynamic page listing more information about the products, but what I’d like to do is give the verified users notice when someone (public or a general site member) clicks the button.
I’d like that information to include their email address and first name or company name.
I tried looking into a custom event with google analytics but that would require admin from my side to send the verified users reports on what is happening, when generally I’d like this to be automated?
If it is a site member then you will already be able to take the details from the logged in user through code. However, if it a public user, then unless you create a form for them to fill in, then you won’t be able to capture their details beforehand.
Thank you, I’m not really a coding master, or ninja, or grasshopper. Is there a tutorial or walkthrough for this?
@givemeawhisky Thank you.
I’ve got the repeater, DB & most other things set up.
What I’m trying to setup is that when a user clicks on something in the repeater which has been loaded by an approved user, that the approved user gets an email or notification of the site user that has clicked it.
I have set page permissions to require a user login, so everyone who would click this now would have to provide their details
I tried to use the Create Custom Events code with google analytics, but again, I’d need to manually then send the verified users this information where I’d rather have it automated
Got this right with onClick functions! And while doing so, moved data from the Members Dataset to a record dataset using the following code:
import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
let user = wixUsers.currentUser;
$w.onReady(function () {
wixData.get("Members/PrivateMembersData", wixUsers.currentUser.id)
.then((results)=>{
let name = results.name;
let firstName = results.firstName;
let lastName = results.lastName;
let email = results.loginEmail;
$w('#txtCurrentUser').text = name ;
$w('#txtFirstName').text = firstName ;
$w('#txtLastName').text = lastName ;
$w('#txtEmail').text = email ;
//NOT WORKING $w('#txtIpAddress').text = ipAddress ;
});
let url = wixLocation.url;
let locale = wixWindow.locale; // "en-US"
let browserLocale = wixWindow.browserLocale; // "en-US"
let formFactor = wixWindow.formFactor; // "Mobile"
let viewMode = wixWindow.viewMode; // "Site"
let referrer = wixWindow.referrer; // "http://somesite.com"
wixWindow.getCurrentGeolocation()
.then( (obj) => {
let timestamp = obj.timestamp; // NOT WORKING
let latitude = obj.coords.latitude; // NOT WORKING
let longitude = obj.coords.longitude; // NOT WORKING
let altitude = obj.coords.altitude; // NOT WORKING
let accuracy = obj.coords.accuracy;// NOT WORKING
let altAccuracy = obj.coords.altitudeAccuracy;// NOT WORKING
let heading = obj.coords.heading;// NOT WORKING
let speed = obj.coords.speed;// NOT WORKING
$w('#txtURL').text = url;
$w('#txtLocale').text = locale;
$w('#txtBrowserLocale').text = browserLocale;
$w('#txtFormFactor').text = formFactor;
$w('#txtViewMode').text = viewMode;
$w('#txtReferrer').text = referrer;
$w('#txtTimestamp').text = timestamp;
$w('#txtLatitude').text = latitude;
$w('#txtLongitude').text = longitude;
$w('#txtAltitude').text = altitude;
$w('#txtAccuracy').text = accuracy;
$w('#txtAltAccuracy').text = altAccuracy;
$w('#txtHeading').text = heading;
$w('#txtSpeed').text = speed;
});
});
$w.onReady(() => {
$w("#YourDatasetName").onReady(() => {
$w("#YourRepeaterName").onItemReady(($item, itemData, index) => {
$item('#YourButtonName').onClick(() => {
$item('#YourButtonName').target = '_blank';
setFieldValues();
$w('#trackingData').setFieldValue("title", $item('#dataset3').getCurrentItem().title);
$w('#trackingData').setFieldValue("companyName", $item('#dataset3').getCurrentItem().companyName);
$w('#trackingData').setFieldValue("link", $item('#dataset3').getCurrentItem().link);
$w('#trackingData').save()
.then(()=> {
let currentItem = $item('#dataset3').getCurrentItem().link;
wixLocation.to(`${currentItem}`);
console.log(currentItem);
});
});
});
});
});
function setFieldValues() {
$w('#trackingData').setFieldValue("email", $w('#txtEmail').text);
$w('#trackingData').setFieldValue("firstName", $w('#txtFirstName').text);
$w('#trackingData').setFieldValue("lastName", $w('#txtLastName').text);
$w('#trackingData').setFieldValue("pageClicked", $w('#txtURL').text);
$w('#trackingData').setFieldValue("locale", $w('#txtLocale').text);
$w('#trackingData').setFieldValue("browserLocale", $w('#txtBrowserLocale').text);
$w('#trackingData').setFieldValue("formFactor", $w('#txtFormFactor').text);
$w('#trackingData').setFieldValue("viewMode", $w('#txtViewMode').text);
$w('#trackingData').setFieldValue("referrer", $w('#txtReferrer').text);
$w('#trackingData').setFieldValue("timestamp", $w('#txtTimestamp').text);
$w('#trackingData').setFieldValue("latitude", $w('#txtLatitude').text);
$w('#trackingData').setFieldValue("longitude", $w('#txtLongitude').text);
$w('#trackingData').setFieldValue("altitude", $w('#txtAltitude').text);
$w('#trackingData').setFieldValue("accuracy", $w('#txtAccuracy').text);
$w('#trackingData').setFieldValue("altAccuracy", $w('#txtAltAccuracy').text);
$w('#trackingData').setFieldValue("heading", $w('#txtHeading').text);
$w('#trackingData').setFieldValue("speed", $w('#txtSpeed').text);
}