Table of Contents
This document describes how to create and add a Tweet link widget to a website.
Allow website visitors to click a link to tweet (from their Twitter account) pre-written content.
And here's the fun part.. the Tweetable content is stored in an attribute which means you can dynamically change it! So even though everyone clicks the same "click to tweet" link, they needn't get the same content.
It's an easy way for your audience to tweet about and share your content, spreading it and reaching new audiences.
You can also count the number of clicks on your link and/or change the default tweet from Conducttr without modifying the website code.
The code snippets we provide ( you can find it on GitHub) must be embedded into a website.
The code will make an API Call to Conducttr, get the twitter text from a Project Attribute, and then a pop-up window will appear with pre-written text for the audience to tweet.
Each recipe has the following sections:
- Ingredients - what you need to complete this project
- Preparation - how to prepare
- Method - step-by-step guide
You will need:
- A website. This recipe will work with any website including free website builders like Wix.com
- The Conducttr Tweet Link widget code(found it on GitHub)
- Basic text-ending software to edit the code such as Notepad
Before following the Method section, please do the following:
- Create a Conducttr project using the Template "Tweet Link"
- Create new API entry inside Conducttr (call it "Tweet Link")
- If you are using the template open the API entry "Tweet Link", go to the Authentication Tab, and Reset your Consumer Key
If you are using the template the basic logic has been already implemented (attributes, methods and triggers) you just need to update the widget code and embed it in your website.
If you want a create the logic from scratch, or modify the existing logic, these are the steps to achieve it:
- Create the attributes
- Create unauth API method in Conducttr.
- Count the clicks (optional)
- Update the tweet link widget code snippet with details from your project
- Embed the code at the website
- Check log to see that video is calling Conducttr as expected
The code is here
First we need to create an attribute to store th default text for your tweet link. Go to the Attibutes panel, select Project as the entity. Create a new Single-line attribute call it "Tweet link"
Tweet Link click count (Optional)
If you want to count easily how many people click in your tweet link we can do it using another attribute. Go to the Attibutes panel, select Project as the entity. Create a new integer attribute call it "Tweet Link click count"
Inside the previously created API entry, go to the API Methods tab and create a new unauth method. The name of the method should be “unauth/[YOUR-METHOD-NAME]” by default it should be unauth/get_tweet_link
Then add all the parameter Tweet link you have created in the previous step with the name "tweet_link"
If you want to count the number of clicks you can create an unauth API trigger with a matchphrase, this will fire when someone clicks the button. You can use the API METHOD NAME as a matchphrase, and then attach a Logic Action to this trigger.
Create a new API Call trigger with the matchphrase “unauth/[YOUR-METHOD-NAME]” by default it should be unauth/get_tweet_link
Then attached to this trigger create a new Logic Action to increment our Project attribute Tweet link count click by 1 each time someone clicks
When you open the code snippet, the area that you edit is between two comment lines. The start of the editable area says “Edit the information below” – as shown in the image.
You need to update the following information:
- CONSUMER KEY – you’ll find this in the Authentication section of the API pop-up
- PROJECT ID – this is found in the top header bar
- METHOD NAME - The API method name and/or the API Trigger matchphrase
By default this is "unauth/get_tweet_link", if you change this name make sure you also change the API Method in your API entry as well (2.3.3 Create unauth API method)
Once you have changed these three parameters you can copy the code and embed it in your website.
Check your Projects Activity Feed to check if Conducttr is correctly receiving the API Calls from the widget.
You can also check your Project attribute "Tweet Link click count" to count how many people have clicked in the link.