How to find names of variabels on my own website?

100 Views Asked by At

I want to implement the Trustpilot javascript extension to my own webshop, to make it possible to get automated productreviews based on the people that visit my checkout page.

I managed in Google Tag Manager to set get a trigger, when someone is visiting my /checkout/thankyou page and send a invitation to Trustpilot. They gave me an example JS code to send the inventation to Trustpilot. I'm now only stuck on the actual code to send... I added the sample code below.

Question: They say... that I have to replace the 'VARIABLE_$EMAIL* with my own 'true variables'? But how on earth do I find my true variable names?

Thank you in advance,

Greetings, Jitske

<script> 
    document.addEventListener('DOMContentLoaded', function() {
        const trustpilot_invitation = {
            recipientEmail: 'VARIABLE_$EMAIL',
            recipientName: 'VARIABLE_$NAME',
            referenceId: 'VARIABLE_$ORDERID',
            source: 'InvitationScript',
            productSkus: 'VARIABLE_$SKU',
            products: [{
                    sku: 'VARIABLE_$SKU',
                    productUrl: 'VARIABLE_$PRODUCTURL',
                    imageUrl: 'VARIABLE_$IMAGEURL',
                    name: 'VARIABLE_$PRODUCTNAME',
                }],
        };
        tp('createInvitation', trustpilot_invitation);
    });
</script>
1

There are 1 best solutions below

2
On

From their support site I found this, which explains a bit more what is needed.

document.addEventListener('DOMContentLoaded', function() {
    const trustpilot_invitation_data = {
        recipientEmail: '[email protected]',
        recipientName: 'John',
        referenceId: 'Order_123',
        source: 'InvitationScript',
        productSkus: ['sku_1', 'sku_2'],
        products: [{
                sku: 'sku_1',
                productUrl: 'https://your_shop.com/product/1',
                imageUrl: 'https://your_shop.com/product/images/1',
                name: 'test_product_1',
            },
            {
                sku: 'sku_2',
                productUrl: 'https://your_shop.com/product/2',
                imageUrl: 'https://your_shop.com/product/images/2',
                name: 'test_product_2',
            }
        ],
    };
    tp('createInvitation', trustpilot_invitation_data);
});

So you actually need to parse the email and other info from your page, and add it to this javascript snippet.