Support

Support is part of Event Gallery Extended.

Please get a subscription if you need support. Feel free to use the ticket system or the contact form for reporting defects or pre-sale questions. Make sure you're logged in in order to be able to create a new ticket.

For general information you can also jump to the manual.

Subscribe now!

#4178 Customers code for Trustpilot javascript?

Posted in ‘Event Gallery - General’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Latest post by sbluege on Sunday, 12 December 2021 16:59 UTC

Kris

Hi,

I want to trigger an automated script from Trustpilot when customers check out from their cart.

I managed to verify my site on Trustpilot and somehow I can activate Trustpilot's automated email script.

Originally the code was 'John@gmail.com' instead of '{$data->order->email|escape}' etc...

The original code activates the script.

But when I want to edit the code with customer data from EventGallery's email template the script doesn't work.

<script> 
	document.addEventListener('DOMContentLoaded', function() {
		const trustpilot_invitation = {
   			recipientEmail: '{$data->order->email|escape}',
   			recipientName: '{$data->order->billingaddress->firstname}',
   			referenceId: '{$data->order->documentnumber}',
   			source: 'InvitationScript',
  		};
  		tp('createInvitation', trustpilot_invitation);
	});
</script>

I put this code in my index.php, but according to Trustpilot's documentation it should be in the review html section. (Very limited explanation on Trustpilot on this topic)

Should I use different codes for my customer data or put the script somewhere else for instance /html/com_eventgallery/checkout/review.php ? But there is no <head> section.

I hope you could help me.

Best regards.

Kris

 

sbluege

Hi, 

I suggest putting it to the confirmation site. Anyhow, this is up to you, I have no clue about thrust pilot.  PHP needs to render this script to fill it with the correct data. You script contains only some placeholders which will do nothing. In review.php or confirm.php you have the $order object which you can use to retrieve data from. I recommend updating to Event Gallery 4.0 before you override data.

You can try to solve this with JS only, too. Just add the script and get the data by parsing some elements on the confirmation page. Joomla adds some useful CSS classes (view-checkout layout-confirm task-confirm) to the body which you can use for a condition when this script should execute. But that is a lot of JS magic :)

Kris

Hi Sven,

Whatever I do, I can't get it done. Here is the new code that I think will allow me to get the customer data.

Can you tell me if this information is correct?

<script> 
	document.addEventListener('DOMContentLoaded', function() {
		const trustpilot_invitation = {
   			recipientEmail: '$order->getEMail()',
   			recipientName: '$order->getName()',
   			referenceId: '$order->getDocumentNumber()',
   			source: 'InvitationScript',
  		};
  		tp('createInvitation', trustpilot_invitation);
	});
</script>

It is possible to create a code within the email template, but unfortunately there is no option to send emails in BCC.

I thought about triggering a fourth automated email, but I can't, there's no option.

Best regards

Kris

sbluege

You can't do this in the email template. Even if this would work, no sane email client will execute JavaScript. 

What do you actually want to do? I read what you wrote above, but it does not make fully sense to me.

Kris

"You can't do this in the email template. Even if this would work, no sane email client will execute JavaScript."
Is correct for email template is different code.

The whole idea is that over time, customers will be invited to give me a review on Trustpilot. This can be automated when they purchase photos and checkout. For this to work I need to implement a script on my website provided by Trustpilot. This script extracts the customer's name, email address, and order ID. The script will send this info to my account on Trustpilot. Then they will receive a personal email with their order ID, just like your email templates, to rate me.

All of this is important for my SEO and higher ranking in search engines like Google.

What I need to know is how do I get the code correct to extract the customers name, email and orde ID?

 

sbluege

Adding something to email and order confirmation pages will have no SEO impact.

If you modify /components/com_eventgallery/view/checkout/tmpl/confirm.php and add this at the bottom, you'll have the Script-Tag incl. data on your page. This is as far as I can help without building the integration for you.

 

<script> 
	document.addEventListener('DOMContentLoaded', function() {
		const trustpilot_invitation = {
   			recipientEmail: '<?php echo $order->getDocumentNumber(); ?>',
   			recipientName: '<?php echo $this->escape($order->getFirstname()) ?> <?php echo $this->escape($order->getLastname()) ?>',
   			referenceId: '<?php echo $this->escape($order->getEMail()) ?>',
   			source: 'InvitationScript',
  		};
  		tp('createInvitation', trustpilot_invitation);
	});
</script>

 

You need to add the trust pilot JavaScript on top, otherwise this will create a JavaScript error. 

Sidenote: please do not modify files of Event Gallery! This is okay for testing, but every update will remove those changes. Use template overrides instead. 

Kris

This is the trick, you are an angel!!!
But I added this at the bottom of confirm.php and everything at the checkout is left aligned now.
But no worries I will fix this.

And this also, the name of my customer at my Trustpilot account is 'client' email and order ID are correct.

"Adding something to email and order confirmation pages will have no SEO impact."
True, but extra stars will give me (I hope) extra clicks.

I appreciate the time you spend with me to resolve this.

Best regards and thanks.
Kris

 

sbluege

You're welcome. I'll close the ticket.