Ana DEV
Ana DEV

Reputation: 1030

How to track link click in email sent to user with php mail function

I have a contact form with Email, Message, Name fields.When user filled this info he/she received like autentification email with link to go and confirm.in this period info shouldnt be filled in Database.When user go with this link then info should be filled in Db with ajax php mail.

My question is how can track this click and when this link is clicked make an ajax request to fill info to Db and send an email with the Details.Am using wordpress, for mail using php mail function.

Upvotes: 2

Views: 1526

Answers (1)

Veve
Veve

Reputation: 6748

1) When you're creating the mail, generate an unique identifier and record it in your database in association with your user.

2) Insert this unique identifier into your link as a parameter.

3) When the user clicks on that link in the mail he/she received, he/she'll arrive on a page of your website/application, where a JS script of your own will read the identifier from the parameter in the URL by which the user arrived, and send it via ajax to your backend.

4) On your backend, you'll just have now to register the visit for this identifier, each time you receive a call from the ajax script.

Personnaly I'll use directly the backend without any ajax call to register the visit at the moment the user load the page.

Upvotes: 3

Related Questions