https://github.com/solidusio-contrib/solidus_klaviyo
Klaviyo integration for the Solidus eCommerce platform.
https://github.com/solidusio-contrib/solidus_klaviyo
ecommerce email klaviyo marketing solidus tracking
Last synced: 8 months ago
JSON representation
Klaviyo integration for the Solidus eCommerce platform.
- Host: GitHub
- URL: https://github.com/solidusio-contrib/solidus_klaviyo
- Owner: solidusio-contrib
- License: bsd-3-clause
- Created: 2020-07-20T10:30:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-13T19:56:10.000Z (almost 3 years ago)
- Last Synced: 2024-12-20T14:33:03.148Z (over 1 year ago)
- Topics: ecommerce, email, klaviyo, marketing, solidus, tracking
- Language: Ruby
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 2
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# solidus_klaviyo
[](https://circleci.com/gh/solidusio-contrib/solidus_klaviyo)
This extension allows you to integrate your [Solidus](https://solidus.io) store with
[Klaviyo](https://klaviyo.com) via [solidus_tracking](https://github.com/solidusio-contrib/solidus_tracking).
## Installation
Add solidus_tracking and solidus_klaviyo to your Gemfile:
```ruby
gem 'solidus_tracking', github: 'solidusio-contrib/solidus_tracking'
gem 'solidus_klaviyo', github: 'solidusio-contrib/solidus_klaviyo'
```
Bundle your dependencies and run the installation generator:
```console
$ bundle
$ bundle exec rails g solidus_klaviyo:install
```
The generator will create an initializer at `config/initializers/solidus_klaviyo.rb` with the
default configuration. Take a look at the file and customize it to fit your environment.
## Usage
### Tracking standard events
In order to track all standard events in Klaviyo, add the following to your
[solidus_tracking](https://github.com/solidusio-contrib/solidus_tracking) configuration:
```ruby
SolidusTracking.configure do |config|
config.trackers << SolidusKlaviyo::Tracker.from_config
end
```
That's it! Your events will be automatically sent to Klaviyo.
### Subscribing users to lists
If you want to subscribe a user to a Klaviyo list, the extension provides a handy Ruby API to do
that:
```ruby
SolidusKlaviyo.subscribe_now('YOUR_LIST_ID', 'jdoe@example.com', custom_property: 'value')
```
We recommend using the built-in background job to subscribe users, in order to avoid blocking your
web workers and slowing down the customer:
```ruby
SolidusKlaviyo.subscribe_later('YOUR_LIST_ID', 'jdoe@example.com', custom_property: 'value')
```
#### Subscribing all users upon signup
If you want to subscribe all users when they sign up, you can just set the `default_list`
configuration option:
```ruby
# config/initializers/solidus_klaviyo.rb
SolidusKlaviyo.configure do |config|
# ...
config.default_list = 'klaviyoListId'
end
```
Now, all users will be subscribed to the configured list automatically when their account is
created.
### Updating users on your lists
Updating an existing user on a list is just as easy as adding them.
```ruby
SolidusKlaviyo.update_now('YOUR_LIST_ID', 'jdoe@example.com', custom_property: 'value')
```
Just like with subscribing, we recommend using the built-in background job to update users,
in order to avoid blocking your web workers and slowing down the customer:
```ruby
SolidusKlaviyo.update_later('YOUR_LIST_ID', 'jdoe@example.com', custom_property: 'value')
```
Updating in bulk is also possible using the `bulk_update_now` and `bulk_update_later` methods.
For bulk updates, you'll want to provide the emails and custom properties in a single object,
like so:
```ruby
SolidusKlaviyo.bulk_update_later('YOUR_LIST_ID', [{email: 'jdoe@example.com', custom_property: 'value'}])
```
## Development
### Testing the extension
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
`bin/rake extension:test_app`.
```console
$ bundle
$ bin/rake
```
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
```console
$ bundle exec rubocop
```
When testing your application's integration with this extension you may use its factories.
Simply add this require statement to your spec_helper:
```ruby
require 'solidus_klaviyo/factories'
```
### Running the sandbox
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
`sandbox/bin/rails`.
Here's an example:
```console
$ bin/rails server
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
* Listening on tcp://127.0.0.1:3000
Use Ctrl-C to stop
```
### Releasing new versions
Your new extension version can be released using `gem-release` like this:
```console
$ bundle exec gem bump -v VERSION --tag --push --remote upstream && gem release
```
## License
Copyright (c) 2020 Nebulab Srls, released under the New BSD License.