Newsletter Signup

Glopal takes your existing site as the source when deliverying localized sites. Glopal automatically adapts experience for the buyer, rewriting all links, translating text and localizing prices as required.

Any action that user does on the localized site (adding product to the wishlist or the cart, or signing up for the newsletter) will be processed as if user is doing the same action on your existing source site.

Sometimes you may want to capture localization context, eg. to recognize that user is visiting your Spanish localized site and process newsletter signup knowing that user should be added to the Spanish users newsletter group.

Glopal offers access to this localization context:

  1. As HTTP headers for server-side customizations

  2. As JavaScript global variable for JavaScript customization

Let us show two possible customizations to record country of the visitor for newsletter signup.

Client Side customization

Create additional (hidden) field for your newsletter form, that should produce HTML similar to:

<input type="hidden" name="country" id="newsletterCountry" />

Now using Glopal's JavaScript global variable we can automatically set hidden field value

const field = document.getElementById("newsletterCountry");
field.value = glopal.config.target.countryCode;

Some form builders may allow defining dynamic value directly, in such case you can use glopal.config.target.countryCodeas dynamic JS value.

Server Side customization

If you have your own custom backend code that is receiving form submission, you can get country of the localized site from X-GlopalHTTP headers, for example:

<?php

...
$country = $_SERVER['X_GLOPAL_COUNTRY'];

save_signup($data, $country);

Last updated